Fix #13881: Add plugin to disallow bytearray as filename in compile()
In Python 3.12 and later, passing a bytearray as the filename argument to
compile() is no longer allowed. This commit adds a mypy plugin that checks
for 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
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 compile's filename argument. ~~Probably to StrPath | bytes, but I haven't looked too deeply into it.~~ Probably StrOrBytesPath.
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.