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

str-format for fill and align specifiers #18800

Open
jack-tutor opened this issue Mar 13, 2025 · 0 comments
Open

str-format for fill and align specifiers #18800

jack-tutor opened this issue Mar 13, 2025 · 0 comments
Labels

Comments

@jack-tutor
Copy link

Feature

The fill and align string format specifiers do not currently have type checking, but are not supported by all types. Specifically, None does not support them.

Pitch

I ran into a bug where an optional type was being passed to string formatting using <. This would succeed most of the time, but error if the value was None:

>>> "{:<2}".format(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to NoneType.__format__

It would be great if mypy would catch this code as a type violation.

I attempted to implement here: #18799 but this was more challenging than I anticipated and I am a first time contributor.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant