-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Document new source finding behaviour #9923
Conversation
This should cover the current state on master, as previously discussed / implemented across python#9742, python#9683, python#9632, python#9616, python#9614, etc. This will need to be changed if we can make `--namespace-packages` the default (python#9636). I haven't documented some of the finer points of the changes, since it felt like an inappropriate level of detail (e.g. using absolute paths when crawling, how directories with invalid package names affect crawling, etc)
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 for documenting this! Specifying the files to type check can be a little tricky, especially when namespace packages are used, so documenting it in detail is very useful.
Looks good, just a few minor comments.
docs/source/running_mypy.rst
Outdated
|
||
$ mypy file_1.py foo/file_2.py file_3.pyi some/directory | ||
|
||
This section describes how exactly mypy maps the provided paths | ||
to modules to type check. | ||
|
||
- Files ending in ``.py`` (and stub files ending in ``.pyi``) are | ||
checked as Python modules. | ||
- mypy will check all paths provided that correspond to files. |
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.
Style nit: At the start of a sentence, capitalize 'mypy' (mypy -> Mypy).
docs/source/running_mypy.rst
Outdated
checked as Python modules. | ||
- mypy will check all paths provided that correspond to files. | ||
|
||
- mypy will recursively discover and check all files ending in ``.py`` or |
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.
mypy -> Mypy
docs/source/running_mypy.rst
Outdated
- For each file to be checked, mypy will attempt to associate the file (e.g. | ||
``project/foo/bar/baz.py``) with a fully qualified module name (e.g. | ||
``foo.bar.baz``). The directory the package is in (``project``) is then | ||
add to mypy's module search paths. |
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.
Typo: add -> added
With :option:`--explicit-package-bases <mypy --explicit-package-bases>`, mypy | ||
will locate the nearest parent directory that is a member of the ``MYPYPATH`` | ||
environment variable, the :confval:`mypy_path` config or is the current | ||
working directory. mypy will then use the relative path to determine the |
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.
Should you also mention module search path items from PEP 561 packages?
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.
No (although maybe I misunderstood the question), there isn't an interaction with PEP 561 packages when you pass files:
Line 73 in 9c54cc3
def get_explicit_package_bases(options: Options) -> Optional[List[str]]: |
This should cover the current state on master, as previously discussed / implemented across #9742, #9683, #9632, #9616, #9614, etc. This will need to be changed if we can make `--namespace-packages` the default (#9636). I haven't documented some of the finer points of the changes, since it felt like an inappropriate level of detail (e.g. using absolute paths when crawling, how directories with invalid package names affect crawling, etc) Co-authored-by: hauntsaninja <>
This should cover the current state on master, as previously
discussed / implemented across #9742, #9683, #9632, #9616, #9614, etc.
This will need to be changed if we can make
--namespace-packages
thedefault (#9636).
I haven't documented some of the finer points of the changes, since it
felt like an inappropriate level of detail (e.g. using absolute paths
when crawling, how directories with invalid package names affect
crawling, etc)