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

mypy.ini is missing #2852

Closed
jolaf opened this issue Mar 11, 2019 · 5 comments
Closed

mypy.ini is missing #2852

jolaf opened this issue Mar 11, 2019 · 5 comments
Labels
project: policy Organization of the typeshed project

Comments

@jolaf
Copy link
Contributor

jolaf commented Mar 11, 2019

I have .mypy.ini file that I use for my projects, in my home directory, and it's pretty strict.
It took me some time to find out that all the typeshed test failures I see are due to the fact that mypy finds that config file and uses it to run tests.

Besides this confusion, that can lead to a more serious problem when someone has a relaxed .mypy.ini in one's home, and that could cause the tests to pass while in fact they should not.

Suggestion: having a correct mypy.ini inside the typeshed and configuring all the test scripts to use it explicitly.

Probably something similar should be done for pytype.cfg and .flake8.

@srittau
Copy link
Collaborator

srittau commented Mar 11, 2019

This seems like a good idea to me. What do the other maintainers think?

@jolaf
Copy link
Contributor Author

jolaf commented Mar 11, 2019

Unfortunately I couldn't create an operational fix for mypy_selftest.py.
Whatever I tried, the tests somehow manage to find and use ~/.mypy.ini.

@rchen152
Copy link
Collaborator

A pytype.cfg isn't needed, since the typeshed test uses pytype-single, which is a debugging/testing tool that isn't configurable like the regular pytype tool is, but adding a mypy config file sounds perfectly reasonable to me.

JelleZijlstra pushed a commit that referenced this issue Apr 8, 2021
As requested by #1526.

This addition takes mypy configuration from each distribution metadata file and constructs a single mypy.ini to run with. It assumes there is no mypy.ini but in case we ever need one, it would be simple to add these on top of an existing configuration file.
Might be relevant for #2852

As the issue did not really specify how the configuration would look, I added the following:
- You may add a mypy-tests section to the metadata file.
It looks like this:
[mypy-tests]
[mypy-tests.yaml]
module_name = "yaml"
[mypy-tests.yaml.values]
disallow_incomplete_defs = true
disallow_untyped_defs = true

- module_name can be of the form "a.*" like in mypy.ini.
- You can add several module sections for complex distributions with several modules.
- I added the '--warn-incomplete-stub' option since it is made specifically for typeshed runs. See docs.
@Avasam
Copy link
Collaborator

Avasam commented Jan 16, 2023

mypy.ini (or equivalent) just by itself would be beneficial for editors for more accurate mypy configs. But it'd also mean duplicating the config in the test and there.

@AlexWaygood
Copy link
Member

AlexWaygood commented Jul 22, 2023

I think this is no longer needed for people to get our tests that use mypy to pass locally: command-line flags always override config files for mypy, and all of our scripts that invoke mypy (mypy_test.py, regr_test.py, typecheck_typeshed.py) pass a fairly exhaustive array of command-line flags to mypy these days, so we should be overriding any config a user has in a local ~/.mypy.ini file.

I'm guessing the experience when editing typeshed locally in an IDE could still be improved. But I feel like adding a mypy.ini file could possibly actually just cause confusion in that regard. Typeshed's a pretty unique project when it comes to the question of "how do I run mypy on typeshed?", and each bit of typeshed requires different mypy configs, which is why we pass different command-line flags in each script we have that invokes mypy. If we added a mypy.ini file (or a config section to pyproject.toml), that might lead people to erroneously think that all they need to do to run mypy on typeshed is to do mypy . -- and for typeshed, there's no way to make that work. If somehow they find a way to make mypy . pass locally, they'll then be confused when they submit a PR and find CI failing.

So, in summary: I don't think we should do this :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

No branches or pull requests

5 participants