{"action":"created","issue":{"url":"https://api.github.com/repos/JukkaL/mypy/issues/935","labels_url":"https://api.github.com/repos/JukkaL/mypy/issues/935/labels{/name}","comments_url":"https://api.github.com/repos/JukkaL/mypy/issues/935/comments","events_url":"https://api.github.com/repos/JukkaL/mypy/issues/935/events","html_url":"https://github.com/JukkaL/mypy/issues/935","id":111710077,"number":935,"title":"Accept a list of files, or whole packages, to typecheck","user":{"login":"gnprice","id":28173,"avatar_url":"https://avatars.githubusercontent.com/u/28173?v=3","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JukkaL/mypy/labels/feature","name":"feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-15T21:20:58Z","updated_at":"2015-10-19T23:06:36Z","closed_at":null,"body":"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.\r\n\r\nFor example in mypy itself, to typecheck `mypy/` with all the Python files that make it up. We used to have `tests.py` as a standin for this, but `runtests.py` is more complicated and `mypy runtests.py` doesn't actually check everything. I can use `mypy -m mypy.main`, but that's getting into details about how the code is laid out.\r\n\r\nOne 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\".\r\n\r\nGiven 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.\r\n```\r\n$ mypy -p mypy\r\n```\r\nwould 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 no `mypy/test/data/__init__.py`, or equivalently because you can't `import mypy.test.data.fixtures.list`, this wouldn't pull in `mypy/test/data/fixtures/list.py`, which is just as desired.\r\n\r\nI 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.\r\n\r\n(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.)\r\n"},"comment":{"url":"https://api.github.com/repos/JukkaL/mypy/issues/comments/149372248","html_url":"https://github.com/JukkaL/mypy/issues/935#issuecomment-149372248","issue_url":"https://api.github.com/repos/JukkaL/mypy/issues/935","id":149372248,"user":{"login":"gnprice","id":28173,"avatar_url":"https://avatars.githubusercontent.com/u/28173?v=3","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T23:06:36Z","updated_at":"2015-10-19T23:06:36Z","body":"Sure, renaming `-p` to a long option would be fine -- I think the main use of it would be in scripts for CI anyway (so long as we also have positional `foo/`.) I'd call it just `--package`, as \"recursive package\" is redundant: Python \"packages\" can have packages inside them, and when module `foo.bar.baz` exists it is part of the package called `foo`. See the use of the term in https://docs.python.org/2/reference/simple_stmts.html#the-import-statement and https://docs.python.org/2/tutorial/modules.html#packages .\r\n\r\nI'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\r\n * positional `foo/` means \"all *.py files in the subtree foo/\", which works for casual cases so people don't need to learn anything;\r\n * `--package foo` means the files that are actually in the importable package `foo`, which takes care of subtler cases when necessary;\r\n * both of these and `-m` can be combined any number of times;\r\nand rely on `__init__.py` files to already describe what people are likely to want with `.mypyignore`. When people really need something more custom and ad-hoc, they can always just construct the list themselves and put it on the command line.\r\n"}}