-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Migrate mypy config to pyproject.toml #3936
Migrate mypy config to pyproject.toml #3936
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -74,7 +74,7 @@ def main(bind_host: str, bind_port: int) -> None: | |||
app = make_app() | |||
ver = black.__version__ | |||
black.out(f"blackd version {ver} listening on {bind_host} port {bind_port}") | |||
web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None) | |||
web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None) # type: ignore[arg-type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print
argument accepts Callable[..., None] = print
i.e.
src/blackd/__init__.py:77:81: error: Argument "print" to "run_app" has incompatible type "None"; expected "Callable[..., None]" [arg-type]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is fixed on master: https://github.com/aio-libs/aiohttp/blob/30850babb43a8e28dd2df036776c62fd613d3d89/aiohttp/web.py#L453C5-L453C5. Can you add a comment saying that aiohttp had an incorrect annotation and that it will be fixed once aiohttp releases that code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, thanks
pyproject.toml
Outdated
warn_return_any = true | ||
# Unreachable blocks have been an issue when compiling mypyc, let's try to avoid 'em in the first place. | ||
warn_unreachable = true | ||
disallow_untyped_calls = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of these are included in --strict
:
--strict Strict mode; enables the following flags: --warn-unused-configs, --disallow-any-generics, --disallow-subclassing-any, --disallow-untyped-calls, --disallow-untyped-defs,
--disallow-incomplete-defs, --check-untyped-defs, --disallow-untyped-decorators, --warn-redundant-casts, --warn-unused-ignores, --warn-return-any, --no-implicit-
reexport, --strict-equality, --extra-checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, They are now removed, Thanks
pyproject.toml
Outdated
# CI only checks src/, but in case users are running LSP or similar we explicitly ignore | ||
# errors in test data files. | ||
[[tool.mypy.overrides]] | ||
module = ["tests.data.*", "scripts.*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't ignore errors in scripts. It's fine to have a looser config apply to scripts though, like ignore missing imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I thought about it but then skipped as it'll add few extra ignores in repo.
- Added
type: ignore
where necessary inscripts.*
- Added
types-commonmark
,urllib3
,hypothesmith
asadditional_dependencies
in mypy hook to avoid addingtype: ignore
(let me know if its not the right way)
@JelleZijlstra @hauntsaninja Appreciate any tip you can provide for resolving these failed checks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CI failures look like mypyc isn't picking up the ignore_missing_imports
in the config file. Not sure why that is, but possibly the hatch-mypyc config needs to be tweaked.
@@ -74,7 +74,7 @@ def main(bind_host: str, bind_port: int) -> None: | |||
app = make_app() | |||
ver = black.__version__ | |||
black.out(f"blackd version {ver} listening on {bind_host} port {bind_port}") | |||
web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None) | |||
web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None) # type: ignore[arg-type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is fixed on master: https://github.com/aio-libs/aiohttp/blob/30850babb43a8e28dd2df036776c62fd613d3d89/aiohttp/web.py#L453C5-L453C5. Can you add a comment saying that aiohttp had an incorrect annotation and that it will be fixed once aiohttp releases that code?
I looked into it and seems like adding [tool.hatch.build.targets.wheel.hooks.mypyc]
mypy-args = ["--ignore-missing-imports"] https://github.com/ofek/hatch-mypyc#mypy-arguments fixes the pipeline. However, I feel like its wildcard option and can ignore all imports errors. But, this makes CICD happy. I'm not sure why hatch mypyc hook is not using default If you have any better way, Please suggest, Thanks! |
Description
This PR is focused on streamlining the project's configuration files. Instead of maintaining separate
mypy.ini
file, this PR help us consolidate remaining mypy configuration file within thepyproject.toml
file as per PEP 518. This modification leads to a more concise and organized config files.Relevant PR #3632 (Closed)
Checklist
CHANGES.md
if necessary?