Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type all remaining tests #2820

Merged
merged 45 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3d7ecac
manual annotations
jakkdl Oct 15, 2023
8eb1190
pyannotate --safe
jakkdl Oct 15, 2023
a909b0a
pyannotate --aggressive
jakkdl Oct 15, 2023
6cad193
WIP before merging origin/master
jakkdl Oct 17, 2023
4789fe5
Merge remote-tracking branch 'origin/master' into type_tests
jakkdl Oct 17, 2023
5106905
Merge remote-tracking branch 'origin/master' into type_tests
jakkdl Oct 17, 2023
9dd47b3
enable check_untyped_defs
jakkdl Oct 17, 2023
787b41e
enable disallow_any_generics, fully type highlevel_serve_listers
jakkdl Oct 17, 2023
2edff67
type a bunch of files with few type errors
jakkdl Oct 17, 2023
718baa0
more typing
jakkdl Oct 18, 2023
fdd3df3
type test_file_io
jakkdl Oct 18, 2023
55ece97
type test_subprocess
jakkdl Oct 18, 2023
6d19cd2
type test_threads
jakkdl Oct 18, 2023
e8f0112
finish typing test_guest_mode
jakkdl Oct 18, 2023
7ef03d9
type test_ki
jakkdl Oct 18, 2023
c7ff2e1
type test_multierror
jakkdl Oct 18, 2023
90eb9f6
Merge remote-tracking branch 'origin/master' into type_tests
jakkdl Oct 18, 2023
e873df1
fix some type errors I missed outside of _tests/ - testing/_fake_net.…
jakkdl Oct 18, 2023
ef91fb7
Fix runtime instantation of objects that don't define `__class_getite…
CoolCat467 Oct 18, 2023
97eba76
Missed one of the `Queue`s
CoolCat467 Oct 18, 2023
f3e5a36
Fix not callable issue I just created with the last fix
CoolCat467 Oct 18, 2023
3c50802
fixes after suggestions from teamspen & coolcat <3
jakkdl Oct 19, 2023
7f0121b
fix a few more type errors
jakkdl Oct 20, 2023
8424768
Merge remote-tracking branch 'origin/master' into type_tests
jakkdl Oct 20, 2023
af9b775
enable disallow_any_unimported and disallow_untyped_calls, fix generi…
jakkdl Oct 20, 2023
077092b
readd type: ignore's incorrectly removed, fix type-checking on non-linux
jakkdl Oct 20, 2023
319e6a8
Merge remote-tracking branch 'origin/HEAD' into type_tests
jakkdl Oct 23, 2023
fcdbdbc
fix ruff/mypy issues
jakkdl Oct 23, 2023
16631e9
fix B904 error
jakkdl Oct 23, 2023
84172eb
Merge branch 'master' into type_tests
CoolCat467 Oct 25, 2023
208b1a3
fix after merge + coolcat review
jakkdl Oct 25, 2023
65d41b1
Merge remote-tracking branch 'origin/HEAD' into type_tests
jakkdl Oct 25, 2023
cfbbcea
add --show-fixes to ruff in pre-commit, test show_diff_on_failure
jakkdl Oct 25, 2023
6170384
autofix from pre-commit
jakkdl Oct 25, 2023
90d6cab
fix RTD build error
jakkdl Oct 25, 2023
95fa49e
fix most codecov issues
jakkdl Oct 25, 2023
027279a
pragma: no cov -> pragma: no cover
jakkdl Oct 25, 2023
dee73de
Merge branch 'master' into type_tests
CoolCat467 Oct 28, 2023
21001c2
Merge branch 'master' into type_tests
CoolCat467 Oct 29, 2023
fc0a6d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2023
81f8bf0
minor changes after review comments
jakkdl Oct 30, 2023
d285bc6
Merge remote-tracking branch 'origin/master' into type_tests
jakkdl Oct 30, 2023
3935a82
fix incorrect suppression found by enabling typechecking (!), move ty…
jakkdl Oct 30, 2023
4d25e75
mark lines with # pragma: no cover
jakkdl Oct 30, 2023
43c7d6d
remove redundant tuple
jakkdl Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ skip_covered = True
exclude_lines =
pragma: no cover
abc.abstractmethod
if TYPE_CHECKING:
if TYPE_CHECKING.*:
if _t.TYPE_CHECKING:
if t.TYPE_CHECKING:
@overload
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ repos:
- id: ruff
types: [file]
types_or: [python, pyi, toml]
args: ["--show-fixes"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand Down
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
# "types.FrameType" is more helpful than just "frame"
"FrameType": "types.FrameType",
"Context": "OpenSSL.SSL.Context",
# SSLListener.accept's return type is seen as trio._ssl.SSLStream
"SSLStream": "trio.SSLStream",
}


Expand Down
47 changes: 2 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,56 +77,13 @@ warn_return_any = true
# Avoid subtle backsliding
disallow_any_decorated = true
disallow_any_generics = true
disallow_any_unimported = false # Enable once Outcome has stubs.
disallow_any_unimported = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true

# Enable once other problems are dealt with
check_untyped_defs = true
disallow_untyped_calls = false

# files not yet fully typed
[[tool.mypy.overrides]]
module = [
# tests
"trio/testing/_fake_net",
"trio/_core/_tests/test_guest_mode",
"trio/_core/_tests/test_instrumentation",
"trio/_core/_tests/test_ki",
"trio/_core/_tests/test_local",
"trio/_core/_tests/test_mock_clock",
"trio/_core/_tests/test_multierror",
"trio/_core/_tests/test_multierror_scripts/ipython_custom_exc",
"trio/_core/_tests/test_multierror_scripts/simple_excepthook",
"trio/_core/_tests/test_parking_lot",
"trio/_core/_tests/test_thread_cache",
"trio/_core/_tests/test_unbounded_queue",
"trio/_tests/test_exports",
"trio/_tests/test_file_io",
"trio/_tests/test_highlevel_generic",
"trio/_tests/test_highlevel_open_unix_stream",
"trio/_tests/test_highlevel_serve_listeners",
"trio/_tests/test_highlevel_ssl_helpers",
"trio/_tests/test_scheduler_determinism",
"trio/_tests/test_ssl",
"trio/_tests/test_subprocess",
"trio/_tests/test_sync",
"trio/_tests/test_testing",
"trio/_tests/test_threads",
"trio/_tests/test_timeouts",
"trio/_tests/test_tracing",
"trio/_tests/test_util",
"trio/_tests/test_wait_for_object",
"trio/_tests/tools/test_gen_exports",
]
check_untyped_defs = false
disallow_any_decorated = false
disallow_any_generics = false
disallow_any_unimported = false
disallow_incomplete_defs = false
disallow_untyped_defs = false

[tool.pytest.ini_options]
addopts = ["--strict-markers", "--strict-config"]
Expand Down
2 changes: 1 addition & 1 deletion trio/_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
WouldBlock,
)
from ._ki import currently_ki_protected, disable_ki_protection, enable_ki_protection
from ._local import RunVar
from ._local import RunVar, RunVarToken
from ._mock_clock import MockClock
from ._parking_lot import ParkingLot, ParkingLotStatistics

Expand Down
2 changes: 1 addition & 1 deletion trio/_core/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class _NoValue:


@final
@attr.s(eq=False, hash=False, slots=False)
@attr.s(eq=False, hash=False, slots=True)
class RunVarToken(Generic[T], metaclass=NoPublicConstructor):
_var: RunVar[T] = attr.ib()
previous_value: T | type[_NoValue] = attr.ib(default=_NoValue)
Expand Down
5 changes: 2 additions & 3 deletions trio/_core/_multierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,8 @@ def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackT
else:
# http://doc.pypy.org/en/latest/objspace-proxies.html
def copy_tb(base_tb: TracebackType, tb_next: TracebackType | None) -> TracebackType:
# Mypy refuses to believe that ProxyOperation can be imported properly
# TODO: will need no-any-unimported if/when that's toggled on
def controller(operation: tputil.ProxyOperation) -> Any | None:
# tputil.ProxyOperation is PyPy-only, but we run mypy on CPython
def controller(operation: tputil.ProxyOperation) -> Any | None: # type: ignore[no-any-unimported]
# Rationale for pragma: I looked fairly carefully and tried a few
# things, and AFAICT it's not actually possible to get any
# 'opname' that isn't __getattr__ or __getattribute__. So there's
Expand Down
Loading