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

Add support for Python 3.12 #2175

Merged
merged 7 commits into from
Dec 4, 2023
Merged

Add support for Python 3.12 #2175

merged 7 commits into from
Dec 4, 2023

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Sep 16, 2023

The second Python 3.12 release candidate is out! 🚀

Call to action

We strongly encourage maintainers of third-party Python projects to prepare their projects for 3.12 compatibilities during this phase, and where necessary publish Python 3.12 wheels on PyPI to be ready for the final release of 3.12.0.

Python 3.12.0 final is due out in two weeks: 2023-10-02.

See also https://dev.to/hugovk/help-test-python-312-beta-1508/

@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Merging #2175 (0ef29df) into main (f61affa) will not change coverage.
Report is 6 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2175   +/-   ##
=======================================
  Coverage   99.15%   99.15%           
=======================================
  Files          38       39    +1     
  Lines        3089     3089           
  Branches      748      748           
=======================================
  Hits         3063     3063           
  Misses         15       15           
  Partials       11       11           

@jfcherng
Copy link

jfcherng commented Oct 3, 2023

Get this today after upgrading to py312. I can continue to use py_version = 311 though.

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\jfcherng\Desktop\repos\sdlc\app_launcher\.venv\Scripts\isort.exe\__main__.py", line 7, in <module>
  File "D:\jfcherng\Desktop\repos\sdlc\app_launcher\.venv\Lib\site-packages\isort\main.py", line 1121, in main
    config = Config(**config_dict)
             ^^^^^^^^^^^^^^^^^^^^^
  File "D:\jfcherng\Desktop\repos\sdlc\app_launcher\.venv\Lib\site-packages\isort\settings.py", line 528, in __init__
    super().__init__(sources=tuple(sources), **combined_config)
  File "<string>", line 105, in __init__
  File "D:\jfcherng\Desktop\repos\sdlc\app_launcher\.venv\Lib\site-packages\isort\settings.py", line 261, in __post_init__
    raise ValueError(
ValueError: The python version 312 is not supported. You can set a python version with the -py or --python-version flag. The following versions are supported: ('all', '2', '27', '3', '310', '311', '36', '37', '38', '39')

pyproject.toml

[tool.isort]
py_version = 312

@@ -16,18 +16,18 @@ jobs:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Copy link
Collaborator

@staticdev staticdev Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please all those action versions changes are not relevant for supporting 3.12. Just keep relevant changes in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, would you like them in another PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, much better idea :)

@@ -16,18 +16,18 @@ jobs:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.github/workflows/integration.yml Outdated Show resolved Hide resolved
.github/workflows/integration.yml Outdated Show resolved Hide resolved
.github/workflows/integration.yml Outdated Show resolved Hide resolved
.github/workflows/labeler.yml Outdated Show resolved Hide resolved
.github/workflows/lint.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @hugovk I just have a final comment on your PR, other than that LGTM.

.github/workflows/test.yml Outdated Show resolved Hide resolved
@Guerteltier
Copy link

Guerteltier commented Dec 3, 2023

Wouldn't it be better to actually add support for 3.12 instead of just pretending? (#2175 (comment))
I don't see how this pull request helps anyone.

@hugovk
Copy link
Contributor Author

hugovk commented Dec 4, 2023

Ah right, we need to update and run scripts/mkstdlibs.py.

I did so and got this error:

Traceback (most recent call last):
  File "/private/tmp/isort/scripts/mkstdlibs.py", line 40, in <module>
    invdata = fetch_inventory(FakeApp(), "", url)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sphinx/ext/intersphinx.py", line 183, in fetch_inventory
    f = _read_from_url(inv, config=app.config)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/sphinx/ext/intersphinx.py", line 140, in _read_from_url
    _tls_info=(config.tls_verify, config.tls_cacerts))
                                  ^^^^^^^^^^^^^^^^^^
AttributeError: ('intersphinx inventory %r not fetchable due to %s: %s', 'https://docs.python.org/2.7/objects.inv', <class 'AttributeError'>, "'FakeConfig' object has no attribute 'tls_cacerts'")

Downgrading from latest Sphinx 7.2.6 to 6.2.1 worked fine. It also updated the 3.11 list.

Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added a new suggestion and if possible could you rebase since we merged some other changes?

scripts/mkstdlibs.py Outdated Show resolved Hide resolved
@hugovk
Copy link
Contributor Author

hugovk commented Dec 4, 2023

Let's also remove unsupported versions.

Also remove their old files from https://github.com/PyCQA/isort/tree/main/isort/stdlibs?

@staticdev
Copy link
Collaborator

Let's also remove unsupported versions.

Also remove their old files from https://github.com/PyCQA/isort/tree/main/isort/stdlibs?

py2 and py27 yes.

@hugovk
Copy link
Contributor Author

hugovk commented Dec 4, 2023

I decided not to remove them after all, a lot of tests would need updating so I think it's out of scope for this PR.

@staticdev staticdev merged commit 885f6ad into PyCQA:main Dec 4, 2023
18 of 21 checks passed
@hugovk hugovk deleted the add-3.12 branch December 5, 2023 07:14
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.

4 participants