-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
_WriteTextMode etc. results in very unhelpful typing errors #6719
Comments
Finding these kinds of problems is exactly what static type checking is intended for. We won't change this in typeshed. In your custom function you can either use the mode aliases from |
You might like my |
Thank you for your quick reply!
This is the core of the disagreement. This repository is called
But there is the Anyway, I am sorry for being so blunt in the top post. I could have phrased it in a much less abrasive manner. What it comes down to fundamentally is that I feel that I more generic use with
Thank you for providing a clear motivation for why this is the case and also providing possible alternatives. (Almost) Happy New Year! |
Typeshed now avoids |
Example
This results in suggestions like this:
This is ridiculous.
Mode is a
str
nothing more, nothing less. It is good that the typesystem checks that I do not accidentally pass anint
or afloat
or aList[str]
but this is taking it way too far. It is extremely unhelpful, it leads to an enormous amount of bloat in the code. Is it really required for me to write every acceptedLiteral
mode under the sun? This is creating them times n
problem all over again.I guess this can be solved by adding a simple
def open(filename: Union[str, bytes, PathLike[str], PathLike[bytes]], mode: str, compresslevel: int = ..., encoding: Optional[str] = ..., errors: Optional[str] = ..., newline: Optional[str] = ...) -> ...
definition to typeshed, so I will do that in a PR.The text was updated successfully, but these errors were encountered: