-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Accept a list of files, or whole packages, to typecheck #935
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
Comments
We currently do our argument parsing by hand, it would probably be good to refactor the whole process after deciding on the UI we want. I think that doing more than one |
I have a prototype for allowing No idea if it actually works for multiple sources, but it accepts them, and doesn't fail on the one-source case. |
This would be really nice! I'm not totally sure about |
Yeah, I thought about having a rule like that and figured it would be surprising to people -- generally if I pass a directory to a command, I expect the command to operate on the whole tree, like You could imagine also supporting passing a directory as a positional argument and meaning to check all the files in that tree. But this is likely to bite you in a different way: if you really have Python files under the tree that don't have a chain of Suppose we accepted positional |
Some additional ideas:
|
Sure, renaming I'd rather have a solution that didn't involve people adding one more kind of special-purpose marker file to their trees. I think we can do
|
I like that! |
+1 |
We've had
We could distinguish these with some other flag, or with a heuristic based on the shape of the filenames or their relationship to the current directory or even to $PYTHONPATH, but it would be nice if both cases just worked without any help. Maybe it would work to crawl up the path until a folder without a init.py is found? |
I'd love to be able to hand mypy a whole library, or a program where it's not totally obvious what the entry point is (or if there is a single entry point), and have it typecheck the whole thing.
For example in mypy itself, to typecheck
mypy/
with all the Python files that make it up. We used to havetests.py
as a standin for this, butruntests.py
is more complicated andmypy runtests.py
doesn't actually check everything. I can usemypy -m mypy.main
, but that's getting into details about how the code is laid out.One interface for this would be to just list a bunch of files as positional arguments to
mypy
. More convenient in many cases would be to say "here's a directory and typecheck everything underneath it".Given the mypy example, actually, where
mypy/test/data/
contains Python files that aren't part of the program, maybe the right option to have there is "here's a Python package and typecheck everything that's part of it". So e.g.would look up
mypy
for import, see that it's a package module, go find all the other files next to its__init__.py
and the directories that themselves contain__init__.py
, and recurse. Because there's nomypy/test/data/__init__.py
, or equivalently because you can'timport mypy.test.data.fixtures.list
, this wouldn't pull inmypy/test/data/fixtures/list.py
, which is just as desired.I think in my ideal version of this interface, you could pass multiple
-m
arguments, multiple-p
arguments, and multiple positional filename arguments, and they'd all just go on the queue together.(In principle I could simulate this by invoking
mypy
once for each file, but that's much slower because it repeats the work of typechecking dependencies.)The text was updated successfully, but these errors were encountered: