Skip to content

Enable --disallow-any-generics for stubs #3288

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

Merged
merged 5 commits into from
Oct 1, 2019

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Oct 1, 2019

As previously, most of these types could probably be tightened down.

Closes #3267

@@ -105,8 +105,6 @@ class Popen(Generic[_T]):
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
def __enter__(self) -> Popen: ...
def __exit__(self, type, value, traceback) -> None: ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are neither described in the documentation, nor could I find them in the implementation, and a short test also showed they don't exist at runtime.

@@ -55,26 +55,26 @@ Boolean: Type[bool]
class DateTime:
value: str
def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[_dateTimeComp, _dateTimeComp]: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[unicode, unicode]: ...
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This could be tightened by using overloads for other.

@@ -12,7 +12,7 @@ from gzip import GzipFile
_Unmarshaller = Any
_timeTuple = Tuple[int, int, int, int, int, int, int, int, int]
# Represents types that can be compared against a DateTime object
_dateTimeComp = Union[AnyStr, DateTime, datetime, _timeTuple]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These methods also accept objects that have a timetuple attribute, but not a tuple itself. This could be solved using a protocol, but I'll leave that to someone else.

@srittau srittau marked this pull request as ready for review October 1, 2019 11:19
@JelleZijlstra JelleZijlstra merged commit c32e1e2 into python:master Oct 1, 2019
@srittau srittau deleted the disallow-any-generic branch October 1, 2019 12:32
@ilevkivskyi
Copy link
Member

Great job! Thank you for all the fixes!

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.

Turn --disallow-any-generics on when checking stubs with mypy
3 participants