-
Notifications
You must be signed in to change notification settings - Fork 96
Update doc string for python 3.12 #418
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
Conversation
Hi @dschwoerer, thanks for your report. This is a bit confusing. I've tried a Python shell session: $ python3.12 --version
Python 3.12.0b2 (main, Jul 7 2023, 07:49:42) [GCC 7.5.0] on linux
$ python3.12
>>> from collections import OrderedDict
>>> OrderedDict({'major': 3, 'minor': 4, 'patch': 5, 'prerelease': None, 'build': None})
OrderedDict({'major': 3, 'minor': 4, 'patch': 5, 'prerelease': None, 'build': None})
>>> OrderedDict([('major', 3), ('minor', 4), ('patch', 5), ('prerelease', None), ('build', None)])
OrderedDict({'major': 3, 'minor': 4, 'patch': 5, 'prerelease': None, 'build': None}) Both syntax variants are possible with Any idea? |
After I've fixed the long line issue, it seems the GitHub Actions are not so happy with your change. 😉 Your "fix" may work for Python 3.12, but breaks the other versions. I'm sorry, but I can't accept this fix as it is. We need to investigate further. |
Ok, I digged deeper and there is a change between 3.12 and the other Python versions. It's in the In Python 3.12 you have this code (see source): @_recursive_repr()
def __repr__(self):
'od.__repr__() <==> repr(od)'
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, dict(self.items())) whereas in Python 3.11 you have this (see source): @_recursive_repr()
def __repr__(self):
'od.__repr__() <==> repr(od)'
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, list(self.items())) The last line is the culprit. Seems we need to change the doctest somehow which does not relate to
Do you have a better idea? |
I do not know doc tests, so I only managed to get the fix for 3.12 As you claim to support 3.12 on pypi, I thought you may be interested :-) It may be best to always return a dict? Do you want me to change it to return dict? That way the doc test would not need to be conditionalised ... Of course, using to list or something could also work ... |
The OrderedDict.__repr__ method was changed in Python 3.12 to output a different string than before (see python-semver#418 for details). The respective doctests which show the output was marked as "skipped" with the above directive. We keep the test for documentation purpuses. In the test tests/test_semver.py::test_should_versioninfo_to_dict we test the keys and values separately.
Thanks for your answer! I think I found a solution to this problem which I committed to 686ce67.
That could indeed an option. I haven't thought about that. 😄 The OrderedDict was introduced due to Python 3.6 as the dict wasn't ordered. As we don't support this version anymore, we might use a simple dict.
Yes, please! That would be great! 👍 You need to adapt these files:
Look for my last commit to see which lines. |
This PR can be closed as #419 is merged now. Thanks! |
Resolves test failure with python3.12:
Failed build and log
Fixed build and log