Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.9k
Fix #13881: Add plugin to disallow bytearray as filename in compile()#14173
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Fix #13881: Add plugin to disallow bytearray as filename in compile()#14173
Conversation
srittau commentedMay 28, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Please note that typeshed only provides type annotations, we don't need or want any custom mypy plugins – that would be detrimental to typeshed's purpose. To solve#13881, we just need to change the type annotations for |
Thank you for the clarification! I'll remove the custom mypy plugin and instead update the type annotation for the filename parameter in the compile() stub to use StrOrBytesPath, as suggested. Appreciate your feedback and guidance on aligning with typeshed's goals. |
In Python 3.12 and later, passing a bytearray as the
filename
argument tocompile()
is no longer allowed. This commit adds a mypy plugin that checksfor this specific misuse and emits an appropriate error message.
The plugin is applied conditionally via mypy.ini and is compatible with the
existing stubs for
compile()
in builtins.pyi.This prevents false positives and ensures correct typing behavior in
accordance with the updated CPython semantics.
Closes#13881