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

Supported Python versions 3.3 to 3.13 #269

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

kieran-ryan
Copy link

@kieran-ryan kieran-ryan commented Dec 23, 2024

🤔 What's changed?

  • Added Python 3.13 support
  • Fixed support for Python 3.3
  • Dropped support for Python 2
  • Enabled mando 0.8.x installations
  • Added notebook extra install (pip install radon[notebook])
  • Added missing toml extra install to poetry build

⚡️ What's your motivation?

Python 2 incompatibility
$ python2.7 -m radon cc project/
Traceback (most recent call last):
  File "/home/codespace/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/home/codespace/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/workspaces/radon/radon/__main__.py", line 4, in <module>
    main()
  File "radon/__init__.py", line 10, in main
    from radon.cli import program, log_error
  File "radon/cli/__init__.py", line 23, in <module>
    from radon.cli.harvest import (
  File "radon/cli/harvest.py", line 6, in <module>
    from builtins import super
ImportError: No module named builtins

This can be resolved by installing futures.

python2.7 -m pip install futures

However an additional error is encountered within configuration parsing.

$ python2.7 -m radon cc project/
Traceback (most recent call last):
  File "/home/codespace/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/home/codespace/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/workspaces/radon/radon/__main__.py", line 4, in <module>
    main()
  File "radon/__init__.py", line 10, in main
    from radon.cli import program, log_error
  File "radon/cli/__init__.py", line 98, in <module>
    _cfg = FileConfig()
  File "radon/cli/__init__.py", line 45, in __init__
    self.file_cfg = self.file_config()
  File "radon/cli/__init__.py", line 85, in file_config
    config.read_dict(FileConfig.toml_config())
AttributeError: RawConfigParser instance has no attribute 'read_dict'

Code optimisations have been largely applied by the ruff linter through its --fix functionality; using the pyupgrade (UP) ruleset.

Python 3.3 incompatibility

Package installation fails with Python 3.3 as installation of an incompatible distribution of colorama is attempted which is only supported from Python 3.4.

py -3.3 -m pip install radon
DEPRECATION: Python 3.3 supported has been deprecated and support for it will be dropped in the future. Please upgrade your Python.
Collecting radon
  Downloading https://files.pythonhosted.org/packages/93/f7/d00d9b4a0313a6be3a3e0818e6375e15da6d7076f4ae47d1324e7ca986a1/radon-6.0.1-py2.py3-none-any.whl (52kB)
    100% |################################| 61kB 596kB/s
Collecting mando<0.8,>=0.6 (from radon)
  Downloading https://files.pythonhosted.org/packages/d2/f0/834e479e47e499b6478e807fb57b31cc2db696c4db30557bb6f5aea4a90b/mando-0.7.1-py2.py3-none-any.whl
Collecting colorama==0.4.1; python_version <= "3.4" (from radon)
  Downloading https://files.pythonhosted.org/packages/4f/a6/728666f39bfff1719fc94c481890b2106837da9318031f71a8424b662e12/colorama-0.4.1-py2.py3-none-any.whl
colorama requires Python '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*' but the running Python is 3.3.5

🏷️ What kind of change is this?

  • 💥 Breaking change (incompatible changes to the API) - although the breaking change (dropping Python 2 support) itself occurred with v6.0.0

♻️ Anything particular you want feedback on?

  • Whether earlier Python 3 versions could be dropped; and if so whether should be part of this pull request or a follow up
  • Whether additional code optimisations could be applied following the removal of Python 2
  • Whether to split any commits into separate pull requests
  • Whether an encoding keyword argument can be provided with open in PyPy

- Update maximum Python version to match `tox.ini` and `README.rst`.
- Add missing support versions 3.3-3.5, 3.10 and 3.11.
@kieran-ryan kieran-ryan force-pushed the fix/supported-pythons branch from 64b972f to 9c1c846 Compare December 23, 2024 18:27
@kieran-ryan kieran-ryan force-pushed the fix/supported-pythons branch 3 times, most recently from 9df08f0 to d335904 Compare December 23, 2024 18:58
`colarama` v0.4.1 is incompatible with Python 3.3
so should not attempt install when using 3.3.
@kieran-ryan kieran-ryan force-pushed the fix/supported-pythons branch from d335904 to a813251 Compare December 23, 2024 21:54
@kieran-ryan kieran-ryan marked this pull request as ready for review December 23, 2024 21:56
- Removed Python 2 references and infrastructure
- Bumped maximum `mando` version to `0.8.x` with Python 2 dropped
- Automatically applied [ruff fixes for Python 2 deprecations](https://docs.astral.sh/ruff/rules/#pyupgrade-up):
  - UP004 - useless-object-inheritance - Class {name} inherits from object
  - UP008 - super-call-with-parameters - Use super() instead of super(__class__, self)
  - UP009 - utf8-encoding-declaration - UTF-8 encoding declaration is unnecessary
  - UP020 - open-alias - Use builtin open
  - UP025 - unicode-kind-prefix - Remove unicode literals from strings
  - UP030 - format-literals - Use implicit references for positional format fields
- Manually resolved `UP036` deprecations (outdated-version-block)
- Dropped deprecated `MAINTAINER` property from `Dockerfile`
- Drop defunct travis CI badge
Simplifies `pip install radon nbformat` to `pip install radon[notebook]`.
Protects against changing underlying dependency in future.
@kieran-ryan kieran-ryan force-pushed the fix/supported-pythons branch from a813251 to 1d2cf66 Compare December 23, 2024 22:18
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.

Please add support for mando 0.8*
1 participant