-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Add type hints to variables.py and platforms.py #1042
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,20 @@ | |
|
||
import warnings | ||
|
||
from pex.typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from pex.pex_info import PexInfo | ||
from pex.variables import Variables | ||
|
||
|
||
class PEXWarning(Warning): | ||
"""Indicates a warning from PEX about suspect buildtime or runtime configuration.""" | ||
|
||
|
||
def configure_warnings(pex_info, env): | ||
if env.PEX_VERBOSE > 0: | ||
# type: (PexInfo, Variables) -> None | ||
if env.PEX_VERBOSE is not None and env.PEX_VERBOSE > 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a bug, although I don't know if we ever hit it. It's possible for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a bug lurking but its unhittable: ... combined with |
||
emit_warnings = True | ||
elif env.PEX_EMIT_WARNINGS is not None: | ||
emit_warnings = env.PEX_EMIT_WARNINGS | ||
|
@@ -24,4 +31,5 @@ def configure_warnings(pex_info, env): | |
|
||
|
||
def warn(message): | ||
# type: (str) -> None | ||
warnings.warn(message, category=PEXWarning, stacklevel=2) |
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.
Note that MyPy doesn't actually know what these are due to the vendoring. But I believe that it will at least check we are using type A, rather than type Z; it just doesn't understand the methods/fields on the type.
And this helpful for the reader.
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.
We can possibly create stubs for these if needed?
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.
Oh, that'd be interesting as a followup once we have higher coverage.
pkg_resources
is pretty key to Pex. Having type hints working with Pex would be great.