Skip to content

Treat --python-version X.Y and --python-version=X.Y in tests equally #8026

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 4 commits into from
Dec 3, 2019

Conversation

ilevkivskyi
Copy link
Member

While working on #8024 I noticed that # flags: --python-version X.Y and # flags: --python-version=X.Y are not treated equally by the test harness, namely the latter is actually ignored. This PR should fix this, because both forms are actually used in tests.

@Michael0x2a there is some suspicious change in literal types, is it expected?

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Good catch! Looks good, modulo possible issue with the updated tests (let's wait for @Michael0x2a to comment on it.)

Copy link
Collaborator

@Michael0x2a Michael0x2a left a comment

Choose a reason for hiding this comment

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

This is probably fine, I think?

I think there's some sort of weird inconsistency going on here due to how we basically always parse pyi files with the Python 3 parser.

For example, here's what happens if we create a dummy.pyi file and run mypy --py2 dummy.pyi:

from typing_extensions import Literal

alias1 = Literal['foo']
alias2 = Literal[b'foo']
alias3 = Literal[u'foo']

a1: alias1
a2: alias2
a3: alias3

reveal_type(a1)  # Revealed type is Literal['foo']
reveal_type(a2)  # Revealed type is Literal['foo']
reveal_type(a3)  # Revealed type is Literal['foo']

b1: Literal['foo']
b2: Literal[b'foo']
b3: Literal[u'foo']

reveal_type(b1)  # Revealed type is Literal[u'foo']
reveal_type(b2)  # Revealed type is Literal['foo']
reveal_type(b3)  # Revealed type is Literal[u'foo']

c1 = ...  # type: Literal['foo']
c2 = ...  # type: Literal[b'foo']
c3 = ...  # type: Literal[u'foo']

reveal_type(c1)  # Revealed type is Literal[u'foo']
reveal_type(c2)  # Revealed type is Literal['foo']
reveal_type(c3)  # Revealed type is Literal[u'foo']

Notice that something wonky happens when we try creating a Literal alias inside the stub files: they seemingly somehow always get converted into bytes. This is obviously surprising: you'd expect the revealed types for a1/a2/a3 to be identical to the other two sets -- or at the very least, for a3 to be unicode.

This is a bug -- but one that's always existed before and is now being properly exposed by this diff, I think?

@ilevkivskyi
Copy link
Member Author

OK, I opened #8062 to track the stub unicode literal alias issue.

@ilevkivskyi ilevkivskyi merged commit 914f0f9 into python:master Dec 3, 2019
@ilevkivskyi ilevkivskyi deleted the fix-pyversion-tests branch December 3, 2019 10:48
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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy