Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 10 additions & 6 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,20 @@ fi

codespell || EXIT_STATUS=$?

PYRIGHT=0
echo "::group::Pyright interface tests"
python src/trio/_tests/check_type_completeness.py --overwrite-file || EXIT_STATUS=$?
if git status --porcelain src/trio/_tests/verify_types*.json | grep -q "M"; then
echo "* Type completeness changed, please update!" >> "$GITHUB_STEP_SUMMARY"
echo "::error::Type completeness changed, please update!"
git --no-pager diff --color src/trio/_tests/verify_types*.json
pyright --verifytypes --ignoreexternal --pythonplatform=Linux --verifytypes=trio \
|| { echo "* Pyright --verifytypes (Linux) found errors." >> "$GITHUB_STEP_SUMMARY"; PYRIGHT=1; }
pyright --verifytypes --ignoreexternal --pythonplatform=Darwin --verifytypes=trio \
|| { echo "* Pyright --verifytypes (Mac) found errors." >> "$GITHUB_STEP_SUMMARY"; PYRIGHT=1; }
pyright --verifytypes --ignoreexternal --pythonplatform=Windows --verifytypes=trio \
|| { echo "* Pyright --verifytypes (Windows) found errors." >> "$GITHUB_STEP_SUMMARY"; PYRIGHT=1; }
if [ $PYRIGHT -ne 0 ]; then
echo "::error:: Pyright --verifytypes returned errors."
EXIT_STATUS=1
fi

pyright trio/_tests/type_tests || EXIT_STATUS=$?
pyright src/trio/_tests/type_tests || EXIT_STATUS=$?
echo "::endgroup::"

# Finally, leave a really clear warning of any issues and exit
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ disallow_untyped_decorators = true
disallow_untyped_defs = true
check_untyped_defs = true

[tool.pyright]
pythonVersion = "3.8"

[tool.pytest.ini_options]
addopts = ["--strict-markers", "--strict-config"]
faulthandler_timeout = 60
Expand Down Expand Up @@ -232,8 +235,6 @@ omit = [
"*/trio/_core/_tests/test_multierror_scripts/*",
# Omit the generated files in trio/_core starting with _generated_
"*/trio/_core/_generated_*",
# Script used to check type completeness that isn't run in tests
"*/trio/_tests/check_type_completeness.py",
]
# The test suite spawns subprocesses to test some stuff, so make sure
# this doesn't corrupt the coverage files
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_asyncgens.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AsyncGenerators:
# init task starting end-of-run asyncgen finalization.
trailing_needs_finalize: _ASYNC_GEN_SET = attr.ib(factory=_ASYNC_GEN_SET)

prev_hooks = attr.ib(init=False)
prev_hooks: sys._asyncgen_hooks = attr.ib(init=False)

def install_hooks(self, runner: _run.Runner) -> None:
def firstiter(agen: AsyncGeneratorType[object, NoReturn]) -> None:
Expand Down
4 changes: 4 additions & 0 deletions src/trio/_core/_wakeup_socketpair.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

class WakeupSocketpair:
def __init__(self) -> None:
# explicitly typed to please `pyright --verifytypes` without `--ignoreexternal`
self.wakeup_sock: socket.socket
self.write_sock: socket.socket

self.wakeup_sock, self.write_sock = socket.socketpair()
self.wakeup_sock.setblocking(False)
self.write_sock.setblocking(False)
Expand Down
194 changes: 0 additions & 194 deletions src/trio/_tests/check_type_completeness.py

This file was deleted.

22 changes: 0 additions & 22 deletions src/trio/_tests/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ def no_underscores(symbols: Iterable[str]) -> set[str]:
if getattr(module, name, None) is getattr(__future__, name):
runtime_names.remove(name)

if tool in ("mypy", "pyright_verifytypes"):
# create py.typed file
py_typed_path = Path(trio.__file__).parent / "py.typed"
py_typed_exists = py_typed_path.exists()
if not py_typed_exists: # pragma: no branch
py_typed_path.write_text("")

if tool == "pylint":
try:
from pylint.lint import PyLinter
Expand Down Expand Up @@ -236,10 +229,6 @@ def no_underscores(symbols: Iterable[str]) -> set[str]:
else: # pragma: no cover
raise AssertionError()

# remove py.typed file
if tool in ("mypy", "pyright_verifytypes") and not py_typed_exists:
py_typed_path.unlink()

# mypy handles errors with an `assert` in its branch
if tool == "mypy":
return
Expand Down Expand Up @@ -289,16 +278,9 @@ def no_hidden(symbols: Iterable[str]) -> set[str]:
if (not symbol.startswith("_")) or symbol.startswith("__")
}

py_typed_path = Path(trio.__file__).parent / "py.typed"
py_typed_exists = py_typed_path.exists()

if tool == "mypy":
if sys.implementation.name != "cpython":
pytest.skip("mypy not installed in tests on pypy")
# create py.typed file
# remove this logic when trio is marked with py.typed proper
if not py_typed_exists: # pragma: no branch
py_typed_path.write_text("")

cache = Path.cwd() / ".mypy_cache"

Expand Down Expand Up @@ -536,10 +518,6 @@ def lookup_symbol(symbol: str) -> dict[str, str]:
"extra": extra,
}

# clean up created py.typed file
if tool == "mypy" and not py_typed_exists:
py_typed_path.unlink()

# `assert not errors` will not print the full content of errors, even with
# `--verbose`, so we manually print it
if errors: # pragma: no cover
Expand Down
55 changes: 0 additions & 55 deletions src/trio/_tests/verify_types_darwin.json

This file was deleted.

Loading