Skip to content

Update type of Formatter.convert_field (missing |None) #11377

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

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Feb 7, 2024

From the source it expects that the second parameter (conversion), can be None:

   def convert_field(self, value, conversion):
        # do any conversion on the resulting object
        if conversion is None:
            return value
   ...

Since at least 17 years according to git blame, as None is refered as early as 11529195cae2438a3ac003babcb1b11af67c4037
And still present in main branch:

https://github.com/python/cpython/blob/ef3ceab09d2d0959c343c662461123d5b0e0b64b/Lib/string.py

From the source it expects that the second parameter (conversion), can
be None:

```python
   def convert_field(self, value, conversion):
        # do any conversion on the resulting object
        if conversion is None:
            return value
   ...
```

Since at least 17 years according to git blame, as None is refered as
early as 11529195cae2438a3ac003babcb1b11af67c4037
And still present in main branch:

https://github.com/python/cpython/blob/ef3ceab09d2d0959c343c662461123d5b0e0b64b/Lib/string.py
Copy link
Contributor

github-actions bot commented Feb 7, 2024

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit edf41ae into python:main Feb 7, 2024
@Carreau
Copy link
Contributor Author

Carreau commented Feb 12, 2024

Thanks !

@hauntsaninja
Copy link
Collaborator

Thank you! :-)

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

Successfully merging this pull request may close these issues.

3 participants