[issue31369] re.RegexFlag is not included in __all__, makes type inference less useful
Guido van Rossum
report at bugs.python.org
Sun Sep 13 14:12:58 EDT 2020
Guido van Rossum <guido at python.org> added the comment:
What it prints is irrelevant to static checking.
Currently the typeshed stub for the code already exports RegexFlag, so that the following passes mypy but fails at runtime:
```
from re import *
def foo(flag: RegexFlag):
return match("[a-z]+", "ABC", flag)
print(foo(IGNORECASE))
print(foo(VERBOSE))
```
I think it's good to add it to `__all__` so this code will not put the type checker to shame, and it would be good to document it.
One thing I discovered when developing this example: there doesn't seem to be a flag to represent 0 (zero), i.e. "no flags". And foo(0) is a type error (even though it works fine at runtime).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31369>
_______________________________________
More information about the Python-bugs-list
mailing list