Skip to content
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 hidden options to disable bytes promotion #13952

Merged
merged 5 commits into from Oct 27, 2022

Conversation

hauntsaninja
Copy link
Collaborator

It might be useful to run mypy_primer without promotions in typeshed. This would give us more confidence in changes stemming from python/typeshed#9001

It might be useful to run mypy_primer without promotions in typeshed.
This would give us more confidence in changes stemming from
python/typeshed#9001
@hauntsaninja hauntsaninja requested a review from JelleZijlstra Oct 27, 2022
@hauntsaninja hauntsaninja changed the title Add options to disable bytes promotion Add hidden options to disable bytes promotion Oct 27, 2022
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks, great idea!

I think this should be a public option in the future as part of mypy's migration plan to implement PEP 688, if and when it is accepted. But for now, it's useful as an undocumented option for typeshed.

mypy/main.py Outdated
@@ -1121,6 +1121,12 @@ def add_invertible_flag(
parser.add_argument(
"--enable-incomplete-features", action="store_true", help=argparse.SUPPRESS
)
parser.add_argument(
"--_disable-bytearray-promotion", action="store_true", help=argparse.SUPPRESS
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we don't need the underscore if we're already suppressing the flag.

@JelleZijlstra
Copy link
Member

You need to run Black though.

@hauntsaninja hauntsaninja merged commit 2d70ac0 into python:master Oct 27, 2022
17 checks passed
@hauntsaninja hauntsaninja deleted the disable-promot branch Oct 27, 2022
hauntsaninja added a commit that referenced this pull request Oct 27, 2022
It might be useful to run mypy_primer without promotions in typeshed.
This would give us more confidence in changes stemming from
python/typeshed#9001
@dvarrazzo
Copy link

Looking forward to testing this! Thank you!

@JelleZijlstra
Copy link
Member

@dvarrazzo fyi, the mypy-primer output in #12661 (comment) should give you an idea of the effect of disabling the promotions on psycopg.

Let me know if you run into any issues where the typeshed stubs don't reflect bytes/bytearray types correctly and I'll help fix them.

@dvarrazzo
Copy link

@JelleZijlstra I'm afraid I'm not very experienced with running mypy if not from packaged releases.

Which repositories should I check out and install in order to try the feature?

Thank you!

@JelleZijlstra
Copy link
Member

The option should be in mypy 0.990, which is expected next week.

In the meantime you can simply install from git with pip install git+https://github.com/python/mypy.git.

@hauntsaninja
Copy link
Collaborator Author

This will be part of 0.990, which should hopefully be out in a week or two: #13871

But as of today, python3 -m pip install -U git+https://github.com/python/mypy.git is the simplest thing you could do. (There are slightly less simple things you could do if you want the mypyc compiled version of mypy, which is much faster)

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.

None yet

3 participants