Skip to content

add difflib.diff_bytes and difflib.Match#1336

Merged
gvanrossum merged 1 commit into
python:masterfrom
JelleZijlstra:diffbytes
May 26, 2017
Merged

add difflib.diff_bytes and difflib.Match#1336
gvanrossum merged 1 commit into
python:masterfrom
JelleZijlstra:diffbytes

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Member

No description provided.

Comment thread stdlib/2and3/difflib.pyi

_T = TypeVar('_T')

Match = NamedTuple('Match', [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suppose you could use the PEP 526 syntax too, but I'll merge as-is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That doesn't work actually, mypy only lets you do that in 3.6.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But IIUC stubs are always processed in 3.6 mode. (Maybe you can try this out?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just tried, in 3.5 mode mypy gives

stdlib/2and3/difflib.pyi:19: error: NamedTuple class syntax is only supported in Python 3.6

Somebody (David I think?) explained that while syntactic 3.6 features work in all stubs, language-level 3.6 features don't. I'm not sure that distinction really makes sense to me, but I guess what it means concretely is that typed_ast processes stubs in 3.6 mode, but mypy's semantic analyzer uses 2.7 mode if mypy is in 2.7 mode, and the semantic analyzer is the place that rejects NamedTuple class syntax.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That must be it. :-(

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