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

TypeError: unsupported format string passed to NoneType.__format__ #2492

Closed
jacobtylerwalls opened this issue Aug 4, 2024 · 2 comments · Fixed by #2496
Closed

TypeError: unsupported format string passed to NoneType.__format__ #2492

jacobtylerwalls opened this issue Aug 4, 2024 · 2 comments · Fixed by #2496
Milestone

Comments

@jacobtylerwalls
Copy link
Member

Regression in #2459

Steps to reproduce

a.py:

class A:
    def __init__(self):
        self._magnitude = None

    def name(self) -> str | None:
        if self._magnitude:
            return f"M {self._magnitude:.1f}"
pylint a.py

Current behavior

  File "/Users/jwalls/release/lib/python3.12/site-packages/astroid/nodes/node_classes.py", line 4778, in _infer_from_values
    yield from nodes[0]._infer(context, **kwargs)
  File "/Users/jwalls/release/lib/python3.12/site-packages/astroid/nodes/node_classes.py", line 4695, in _infer
    formatted = format(value.value, format_spec.value)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to NoneType.__format__
@jacobtylerwalls
Copy link
Member Author

@ericvergnaud would you be available to take a look at this?

@ericvergnaud
Copy link
Contributor

ericvergnaud commented Aug 6, 2024

@ericvergnaud would you be available to take a look at this?

Done, see #2496

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

Successfully merging a pull request may close this issue.

2 participants