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

Replace pkg_resources.parse_version by packaging.version.Version #2037

Merged
merged 2 commits into from Jan 9, 2024

Conversation

berhoel
Copy link
Contributor

@berhoel berhoel commented Dec 17, 2023

PR Summary

PR checklist

Please make sure that the following things have been addressed (and check the relevant checkboxes):

  • Commits respect our guidelines

  • Tests are passing properly (see here on how to run Elpy's tests)
    running ./scripts/test python reports the following problems:

    ======================================================================
    ERROR: test_fix_code (tests.test_yapf.YAPFTestCase.test_fix_code)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/hoel/work/code-root/github.com/elpy/elpy/yapfutil.py", line 31, in fix_code
        reformatted_source, _ = yapf_api.FormatCode(code,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: FormatCode() got an unexpected keyword argument 'verify'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/hoel/work/code-root/github.com/elpy/elpy/tests/test_yapf.py", line 37, in test_fix_code
        self._assert_format(src, expected)
      File "/home/hoel/work/code-root/github.com/elpy/elpy/tests/test_yapf.py", line 40, in _assert_format
        new_block = yapfutil.fix_code(src, os.getcwd())
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/hoel/work/code-root/github.com/elpy/elpy/yapfutil.py", line 37, in fix_code
        raise Fault("Error during formatting: {}".format(e),
    elpy.rpc.Fault: Error during formatting: FormatCode() got an unexpected keyword argument 'verify'
    
    ======================================================================
    FAIL: test_should_complete_top_level_modules_for_import (tests.test_jedibackend.TestRPCGetCompletions.test_should_complete_top_level_modules_for_import)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/hoel/work/code-root/github.com/elpy/elpy/tests/support.py", line 382, in test_should_complete_top_level_modules_for_import
        self.assertEqual(sorted([cand['suffix'] for cand in completions]),
    AssertionError: Lists differ: ['dict', 'processing'] != ['processing']
    
    First differing element 0:
    'dict'
    'processing'
    
    First list contains 1 additional elements.
    First extra element 1:
    'processing'
    
    - ['dict', 'processing']
    ?  --------
    
    + ['processing']
    
    ======================================================================
    FAIL: test_should_get_oneline_docstring_for_modules (tests.test_jedibackend.TestRPCGetOnelineDocstring.test_should_get_oneline_docstring_for_modules)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/hoel/work/code-root/github.com/elpy/elpy/tests/support.py", line 842, in test_should_get_oneline_docstring_for_modules
        self.check_module_docstring(docstring)
      File "/home/hoel/work/code-root/github.com/elpy/elpy/tests/support.py", line 818, in check_module_docstring
        self.assertEqual(docstring['doc'],
    AssertionError: 'JSON[30 chars]<https://json.org> is a subset of JavaScript s[71 chars]mat.' != 'JSON[30 chars]<http://json.org> is a subset of JavaScript sy[70 chars]mat.'
    - JSON (JavaScript Object Notation) <https://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.
    ?                                        -
    + JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format.
    
    
    ----------------------------------------------------------------------
    Ran 317 tests in 18.319s
    
    FAILED (failures=2, errors=1)
    

None of these seems to be related to my changes, in fact I get exact these error messages with the latest upstream code.

For new features only:

  • Tests has been added to cover the change
  • The documentation has been updated

@finjulhich
Copy link

Would this still work with python versions < 3.12?

@gopar
Copy link
Collaborator

gopar commented Dec 17, 2023

Would this still work with python versions < 3.12?

This is a good point. The PR doesn't seem like it'll work with versions < 3.12
PR will need to be updated.

Thanks!

@berhoel
Copy link
Contributor Author

berhoel commented Dec 18, 2023

Would this still work with python versions < 3.12?

This is a good point. The PR doesn't seem like it'll work with versions < 3.12 PR will need to be updated.

Thanks!

My latest update for the patch addresses this by falling back to pkg_resources if importing packaging.version.Version fails.

@coveralls
Copy link

Coverage Status

coverage: 90.96%. remained the same
when pulling 6a6655e on berhoel:master
into 7ff8ffa on jorgenschaefer:master.

@gopar gopar merged commit 777e990 into jorgenschaefer:master Jan 9, 2024
4 of 12 checks passed
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.

None yet

4 participants