| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| # than the interpreter it runs on. Pin it to the running interpreter so ty and | ||
| # mypy agree on which `sys.version_info` branches are reachable. No session | ||
| # pins a python, so this is the version the session venv uses. | ||
| TY_PYTHON_VERSION = f"{sys.version_info[0]}.{sys.version_info[1]}" |
There was a problem hiding this comment.
this does not need a constant or a long comment, the comment can be a single sentence
Sorry, something went wrong.
| "noxfile.py", | ||
| ) | ||
|
|
||
| session.run( |
There was a problem hiding this comment.
in local I think we should replace mypy, and go ty only, since local is optimized for speed
Sorry, something went wrong.
| # (https://github.com/astral-sh/ty/issues/2797). pytest 9 dropped that | ||
| # pattern but requires Python 3.10+, so skip ty on 3.9. | ||
| if sys.version_info < (3, 10): | ||
| session.log("Skipping ty: needs pytest >= 9, which needs Python 3.10+") |
There was a problem hiding this comment.
@reaperhulk I'm pretty sure this means we need to wait for a fix in ty, I don't love landing this with weird skips.
Sorry, something went wrong.
ty and mypy use incompatible suppression comments: ty ignores any
`# type: ignore[...]` that carries error codes in brackets, and mypy
only recognizes `# type: ignore` when it is the first comment on a
line. Lines that both checkers flag now carry a mypy comment followed
by a ty one, which each tool parses as its own. A bare `# type: ignore`
is honored by both, so the sites that already use one are left alone.
Add ty to the pep8test dependency group and run it in the `flake` and
`local` nox sessions. ty resolves its target version from
`project.requires-python` rather than the interpreter it runs on, so
pass `--python-version` to keep it in step with mypy; otherwise the two
disagree about which `sys.version_info` branch is reachable, and ty
demands `tomli` even on interpreters where the fallback import is dead.
Skip ty on Python 3.9. ty binds away the first parameter of a
`__call__` typed through a Callable-bounded TypeVar, which is how
pytest 8's `_WithException` protocol declares it, so every
`pytest.skip("...")` in the suite is rejected. pytest 9 dropped that
pattern but requires Python 3.10+.
Disable ty's `unused-type-ignore-comment`. One arm of a
`sys.version_info` pair is unreachable at any given version, and ty
reports the blanket ignore mypy needs there as unused. mypy's
`warn_unused_ignores` already covers those comments.
`unused-ignore-comment` (for `# ty: ignore`) stays on, since mypy
cannot check those.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FfdhCmHmddyxdZACBwjaeg
| # ty does not understand mypy's error codes, so a line both checkers flag | ||
| # carries a `# type: ignore[...]` followed by a `# ty: ignore[...]`. If ty | ||
| # grows support for mypy's names (https://github.com/astral-sh/ty/issues/3127) | ||
| # the `ty:` halves can be dropped. | ||
| [tool.ty.rules] | ||
| # In `sys.version_info`-gated code one branch is always unreachable, and ty | ||
| # reports the blanket ignore there as unused while mypy stays quiet. Whichever | ||
| # version we check, one arm of such a pair gets flagged. mypy's | ||
| # `warn_unused_ignores` already covers `# type: ignore` comments, so turn this | ||
| # off. `unused-ignore-comment` (for `# ty: ignore`) stays enabled, since mypy | ||
| # can't check those. | ||
| # Tracked upstream as https://github.com/astral-sh/ty/issues/2681; this can be | ||
| # re-enabled once ty stops reporting suppressions in unreachable code. | ||
| unused-type-ignore-comment = "ignore" |
There was a problem hiding this comment.
Instead of this you probably want to use:
[tool.ty.analysis]
respect-type-ignore-comments = falseThat will make ty ignore # type: ignore[...] and only respect # ty: ignore[...] which I've found to be easier.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds ty side-by-side mypy for typechecking.
ty and mypy use incompatible suppression comments: ty ignores any # type: ignore[...] that carries error codes in brackets, and mypy only recognizes # type: ignore when it is the first comment on a line. Lines that both checkers flag now carry a mypy comment followed by a ty one, which each tool parses as its own. A bare # type: ignore is honored by both, so the sites that already use one are left alone.
Add ty to the pep8test dependency group and run it in the flake and local nox sessions. ty resolves its target version from project.requires-python rather than the interpreter it runs on, so pass --python-version to keep it in step with mypy; otherwise the two disagree about which sys.version_info branch is reachable, and ty demands tomli even on interpreters where the fallback import is dead.
Disable ty's unused-type-ignore-comment. One arm of a sys.version_info pair is unreachable at any given version, and ty reports the blanket ignore mypy needs there as unused. mypy's warn_unused_ignores already covers those comments. unused-ignore-comment (for # ty: ignore) stays on, since mypy cannot check those.
Claude-Session: https://claude.ai/code/session_01FfdhCmHmddyxdZACBwjaeg