Skip to content

Commit acb2010

Browse files
committed
tests/test_compile.py: improve types and formatting
Some minor improvements to type annotations and code formatting in tests/test_compile.py.
1 parent 296c9ef commit acb2010

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tests/test_compile.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# SPDX-License-Identifier: MIT
2-
# Copyright (c) 2022 The Pybricks Authors
2+
# Copyright (c) 2022-2026 The Pybricks Authors
33

44

55
import contextlib
66
import os
77
import struct
88
import sys
99
from tempfile import TemporaryDirectory
10+
from typing import Any
1011

1112
import pytest
1213

@@ -16,18 +17,18 @@
1617
if sys.version_info < (3, 11):
1718
from contextlib import AbstractContextManager
1819

19-
class chdir(AbstractContextManager):
20+
class chdir(AbstractContextManager[None]):
2021
"""Non thread-safe context manager to change the current working directory."""
2122

22-
def __init__(self, path):
23+
def __init__(self, path: str) -> None:
2324
self.path = path
24-
self._old_cwd = []
25+
self._old_cwd: list[str] = []
2526

26-
def __enter__(self):
27+
def __enter__(self) -> None:
2728
self._old_cwd.append(os.getcwd())
2829
os.chdir(self.path)
2930

30-
def __exit__(self, *excinfo):
31+
def __exit__(self, *excinfo: Any) -> None:
3132
os.chdir(self._old_cwd.pop())
3233

3334
setattr(contextlib, "chdir", chdir)
@@ -130,10 +131,12 @@ def unpack_mpy(data: bytes) -> tuple[bytes, bytes]:
130131
names.add(name2.decode())
131132
name3, mpy3 = unpack_mpy(multi_mpy)
132133
names.add(name3.decode())
134+
133135
if uses_module_finder:
134136
# ModuleFinder requires __init__.py.
135137
name4, mpy4 = unpack_mpy(multi_mpy)
136138
names.add(name4.decode())
139+
137140
name5, mpy5 = unpack_mpy(multi_mpy)
138141
names.add(name5.decode())
139142

0 commit comments

Comments
 (0)