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

Support invoking mypy from setuptools #994

Closed
wants to merge 1 commit into from

Conversation

rowillia
Copy link
Contributor

By default, this will typecheck all of the package modules.
We still need to figure out how to handle third-party modules.
Passing in --mypy-args="--use-python-path" will also include
any dependent modules, but nearly all of them fail to typecheck.

This will fix #992

@@ -203,6 +203,9 @@ def default_data_dir(bin_dir: str) -> str:
# TODO fix this logic
if not bin_dir:
# Default to directory containing this file's parent.
if os.path.dirname(os.path.dirname(__file__)).endswith('.egg'):
return os.path.join(os.path.dirname(os.path.dirname(__file__)),
'lib', 'mypy')
return os.path.dirname(os.path.dirname(__file__))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's factor out os.path.dirname(os.path.dirname(__file__)) into a local variable so we don't have to repeat it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gnprice
Copy link
Collaborator

gnprice commented Nov 24, 2015

Thanks for sending this in! Will be glad to have this feature. Made some comments.

@rowillia
Copy link
Contributor Author

Thanks for the feedback @gnprice! I dropped comments in to explain some of the less-obvious things, LMK if that makes sense.

By default, this will typecheck all of the package modules.
We still need to figure out how to handle third-party modules.
Passing in `--mypy-args="--use-python-path"` will also include
any dependent modules, but nearly all of them fail to typecheck.

This will fix python#992
@JukkaL
Copy link
Collaborator

JukkaL commented Nov 29, 2015

Sorry for such a basic question, but what exactly is the use case that this solves? I actually don't have context on this issue. (I expect that this is useful thing once I understand this a little better.)

@rowillia
Copy link
Contributor Author

@JukkaL setuptools allows for packages to register new commands. For example, flake8 registers the flake8 command (http://flake8.readthedocs.org/en/latest/setuptools.html). This will enable mypy to be used in the same manner. In my soon-to-be-open source project, it allows python3 setup.py mypy to typecheck everything.

@JukkaL
Copy link
Collaborator

JukkaL commented Dec 1, 2015

Ok, sounds good -- thanks! I just rebased and merged your PR. It would be really nice if you could contribute a documentation update for this :-) (see docs/source in the mypy repo).

@JukkaL JukkaL closed this Dec 1, 2015
@rowillia
Copy link
Contributor Author

rowillia commented Dec 2, 2015

Thanks @JukkaL! I'll update docs as well.

@eric-wieser
Copy link
Contributor

This was closed in 7e42ac8, I'm guessing? Is there a discussion somewhere about why it was reverted in 964a175?

eric-wieser referenced this pull request Feb 13, 2018
By default, this will typecheck all of the package modules.
We still need to figure out how to handle third-party modules.
Passing in `--mypy-args="--use-python-path"` will also include
any dependent modules, but nearly all of them fail to typecheck.

This will fix #992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a setup.py command as a way to invoke mypy
4 participants