Skip to content

Conversation

rowillia
Copy link
Contributor

No description provided.

@@ -939,10 +939,10 @@ class UnicodeWarning(Warning): ...
class BytesWarning(Warning): ...
class ResourceWarning(Warning): ...

def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ...
def eval(s: Union[str, unicode], globals: Dict[Union[str, unicode], Any] = ..., locals: Dict[Union[str, unicode], Any] = ...) -> Any: ...
Copy link
Member

Choose a reason for hiding this comment

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

I believe the dict ones will cause trouble because Dict is invariant in its key type, so now mypy will only let you pass a dictionary whose keys are Union[str, unicode]. Mapping is not correct here either, because eval and exec will modify these dictionaries.

stdlib/2/ast.pyi Outdated
@@ -21,7 +21,7 @@ __version__ = ... # type: str
PyCF_ONLY_AST = ... # type: int


def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> Module: ...
def parse(source: Union[str, unicode, bytes], filename: Union[str, unicode, bytes] = ..., mode: Union[str, unicode] = ...) -> Module: ...
Copy link
Member

Choose a reason for hiding this comment

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

Union[str, bytes] is redundant in Python 2.

@rowillia
Copy link
Contributor Author

@JelleZijlstra addressed the comments, thanks!

@JelleZijlstra
Copy link
Member

Thanks!

@JelleZijlstra JelleZijlstra merged commit 31d7393 into python:master Jun 27, 2017
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.

2 participants