Skip to content

Commit 12e2da8

Browse files
jakkdlCoolCat467pre-commit-ci[bot]
authored
Type all remaining tests (#2820)
* add types to all remaining tests * make trio.ssl.SSLStream and SSLListener generic * export trio.lowlevel.RunVarToken --------- Co-authored-by: CoolCat467 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7773cfb commit 12e2da8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1391
-982
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ skip_covered = True
2020
exclude_lines =
2121
pragma: no cover
2222
abc.abstractmethod
23-
if TYPE_CHECKING:
23+
if TYPE_CHECKING.*:
2424
if _t.TYPE_CHECKING:
2525
if t.TYPE_CHECKING:
2626
@overload

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ repos:
2828
- id: ruff
2929
types: [file]
3030
types_or: [python, pyi, toml]
31+
args: ["--show-fixes"]
3132
- repo: https://github.com/codespell-project/codespell
3233
rev: v2.2.6
3334
hooks:

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
# "types.FrameType" is more helpful than just "frame"
7272
"FrameType": "types.FrameType",
7373
"Context": "OpenSSL.SSL.Context",
74+
# SSLListener.accept's return type is seen as trio._ssl.SSLStream
75+
"SSLStream": "trio.SSLStream",
7476
}
7577

7678

pyproject.toml

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -77,56 +77,13 @@ warn_return_any = true
7777
# Avoid subtle backsliding
7878
disallow_any_decorated = true
7979
disallow_any_generics = true
80-
disallow_any_unimported = false # Enable once Outcome has stubs.
80+
disallow_any_unimported = true
8181
disallow_incomplete_defs = true
8282
disallow_subclassing_any = true
83+
disallow_untyped_calls = true
8384
disallow_untyped_decorators = true
8485
disallow_untyped_defs = true
85-
86-
# Enable once other problems are dealt with
8786
check_untyped_defs = true
88-
disallow_untyped_calls = false
89-
90-
# files not yet fully typed
91-
[[tool.mypy.overrides]]
92-
module = [
93-
# tests
94-
"trio/testing/_fake_net",
95-
"trio/_core/_tests/test_guest_mode",
96-
"trio/_core/_tests/test_instrumentation",
97-
"trio/_core/_tests/test_ki",
98-
"trio/_core/_tests/test_local",
99-
"trio/_core/_tests/test_mock_clock",
100-
"trio/_core/_tests/test_multierror",
101-
"trio/_core/_tests/test_multierror_scripts/ipython_custom_exc",
102-
"trio/_core/_tests/test_multierror_scripts/simple_excepthook",
103-
"trio/_core/_tests/test_parking_lot",
104-
"trio/_core/_tests/test_thread_cache",
105-
"trio/_core/_tests/test_unbounded_queue",
106-
"trio/_tests/test_exports",
107-
"trio/_tests/test_file_io",
108-
"trio/_tests/test_highlevel_generic",
109-
"trio/_tests/test_highlevel_open_unix_stream",
110-
"trio/_tests/test_highlevel_serve_listeners",
111-
"trio/_tests/test_highlevel_ssl_helpers",
112-
"trio/_tests/test_scheduler_determinism",
113-
"trio/_tests/test_ssl",
114-
"trio/_tests/test_subprocess",
115-
"trio/_tests/test_sync",
116-
"trio/_tests/test_testing",
117-
"trio/_tests/test_threads",
118-
"trio/_tests/test_timeouts",
119-
"trio/_tests/test_tracing",
120-
"trio/_tests/test_util",
121-
"trio/_tests/test_wait_for_object",
122-
"trio/_tests/tools/test_gen_exports",
123-
]
124-
check_untyped_defs = false
125-
disallow_any_decorated = false
126-
disallow_any_generics = false
127-
disallow_any_unimported = false
128-
disallow_incomplete_defs = false
129-
disallow_untyped_defs = false
13087

13188
[tool.pytest.ini_options]
13289
addopts = ["--strict-markers", "--strict-config"]

trio/_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
WouldBlock,
1919
)
2020
from ._ki import currently_ki_protected, disable_ki_protection, enable_ki_protection
21-
from ._local import RunVar
21+
from ._local import RunVar, RunVarToken
2222
from ._mock_clock import MockClock
2323
from ._parking_lot import ParkingLot, ParkingLotStatistics
2424

trio/_core/_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class _NoValue:
1717

1818

1919
@final
20-
@attr.s(eq=False, hash=False, slots=False)
20+
@attr.s(eq=False, hash=False, slots=True)
2121
class RunVarToken(Generic[T], metaclass=NoPublicConstructor):
2222
_var: RunVar[T] = attr.ib()
2323
previous_value: T | type[_NoValue] = attr.ib(default=_NoValue)

trio/_core/_multierror.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,8 @@ def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackT
424424
else:
425425
# http://doc.pypy.org/en/latest/objspace-proxies.html
426426
def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackType:
427-
# Mypy refuses to believe that ProxyOperation can be imported properly
428-
# TODO: will need no-any-unimported if/when that's toggled on
429-
def controller(operation: tputil.ProxyOperation) -> Any | None:
427+
# tputil.ProxyOperation is PyPy-only, but we run mypy on CPython
428+
def controller(operation: tputil.ProxyOperation) -> Any | None: # type: ignore[no-any-unimported]
430429
# Rationale for pragma: I looked fairly carefully and tried a few
431430
# things, and AFAICT it's not actually possible to get any
432431
# 'opname' that isn't __getattr__ or __getattribute__. So there's

0 commit comments

Comments
 (0)