Skip to content

str-format for fill and align specifiers #18800

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

Open
jack-tutor opened this issue Mar 13, 2025 · 2 comments · May be fixed by #18952
Open

str-format for fill and align specifiers #18800

jack-tutor opened this issue Mar 13, 2025 · 2 comments · May be fixed by #18952
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.

@ChristinaTrinh
Copy link

Can I try to work on this?

@brianschubert
Copy link
Collaborator

@ChristinaTrinh please, feel free :)

You can check out CONTRIBUTING.md and the Developer Guides for contributing guidelines and tips on where to start. Thanks!

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

Successfully merging a pull request may close this issue.

3 participants