Skip to content

Upgrade Python from 3.9 to 3.10 with deprecated API modernization #28

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

gitar-bot-staging[bot]
Copy link

This PR upgrades the entire codebase from Python 3.9 to Python 3.10, including comprehensive modernization of deprecated Python APIs and modules.

Changes

  • Python version upgrade: Updated Python requirements from 3.9 to 3.10 across all setup.py files and Docker images
  • Deprecated API modernization: Migrated from deprecated modules and APIs to their modern equivalents:
    • parser module → ast module
    • distutilssetuptools
    • imp module → importlib
    • asyncio.coroutine decorator → async def syntax
    • ssl.match_hostname() → ssl context verification
    • threading.Thread.setName()/.getName().name property
    • importlib.abc.Loader.load_module()exec_module()
    • formatter module → string formatting methods
  • Infrastructure updates: Updated CI/CD pipelines, Docker base images, and GitHub Actions to Python 3.10
  • Code quality improvements: Fixed syntax issues like numeric literals followed by keywords spacing

Impact

  • 137 files modified across packages, services, scripts, and CI/CD configurations
  • Ensures compatibility with Python 3.10 and removes deprecated API usage
  • Maintains backward compatibility while modernizing the codebase
  • Improves code maintainability and future-proofs against deprecation warnings

Python 3.10 Benefits

Python 3.10 introduces several improvements including structural pattern matching, better error messages, performance optimizations, and new typing features. See the official Python 3.10 release notes for complete details.

This upgrade ensures the codebase stays current with Python's evolution and removes technical debt from deprecated APIs.


Link to run
Requested by: naveen@gitar.ai

gitar-bot and others added 5 commits July 9, 2025 15:41
…ions in CI/CD configuration files (GitHub Actions, GitLab CI, etc.) from `3.9` to `3.10`.

Update GitHub Actions setup-python to v4: Update GitHub Actions `setup-python` action versions to v4 or later for proper Python 3.10 support.
…rom `python:3.9` to `python:3.10` in Dockerfiles and docker-compose files.
…in setup.py and pyproject.toml files to include Python 3.10 support (e.g., `>=3.8,<3.11` or `>=3.9`).

Update Python dependencies for 3.10 compatibility: Update requirements.txt files to include version constraints compatible with Python 3.10 for all dependencies.
… import` and `from distutils import` statements with `from setuptools import` equivalents, migrating setup.py files from distutils to setuptools.

Migrate distutils Extension to setuptools: Replace `from distutils.extension import Extension` with `from setuptools import Extension` and update related extension building code.
Migrate distutils.command imports to setuptools: Replace `from distutils.command import` imports with setuptools equivalents or custom command implementations.
Update distutils.util function calls with alternatives: Update `distutils.util` function calls like `strtobool()` and `convert_path()` with equivalent implementations or alternative libraries.
Replace distutils.spawn with subprocess.run calls: Replace `distutils.spawn.spawn()` calls with `subprocess.run()` or equivalent process execution methods.
Migrate distutils.version to packaging.version classes: Replace `distutils.version` classes like `LooseVersion` and `StrictVersion` with `packaging.version` equivalents.
Migrate distutils.sysconfig to sysconfig module: Replace `distutils.sysconfig` imports and function calls with `sysconfig` module equivalents for system configuration queries.
…om parser import` statements with equivalent `ast` module usage, converting parser module functions like `parser.expr()` to `ast.parse(..., mode='eval')`.

Remove loop parameter from asyncio API functions: Remove `loop` parameter from asyncio high-level API functions including `create_task()`, `gather()`, `shield()`, `wait_for()`, `wait()`, `as_completed()`, and `run_coroutine_threadsafe()`.
Fix numeric literals followed by keywords spacing: Fix numeric literals immediately followed by keywords by adding whitespace between the number and keyword (e.g., `0in` becomes `0 in`).
Update traceback.format_exception parameter name etype to exc: Replace `traceback.format_exception(etype, value, tb)` parameter name `etype` with `exc` in traceback module function calls.
Migrate formatter imports to string formatting: Replace `import formatter` and `from formatter import` statements by migrating to string formatting methods or removing formatter module usage entirely.
Update threading.Thread deprecated name methods: Replace deprecated `threading.Thread.setName()` and `threading.Thread.getName()` with `threading.Thread.name` property access.
Migrate ssl.match_hostname() to ssl context verification: Replace deprecated `ssl.match_hostname()` function calls with equivalent hostname verification using ssl context or urllib3.
Replace importlib.abc.Loader.load_module with exec_module: Replace `importlib.abc.Loader.load_module()` calls with `importlib.abc.Loader.exec_module()` method implementations.
Update importlib module loading patterns: Replace deprecated `importlib.util.module_for_loader` decorator with updated importlib patterns for module loading.
Replace `imp` module with `importlib` equivalents: Replace deprecated `imp` module imports with `importlib` equivalents for dynamic module importing and loading.
Replace asyncio.coroutine with async def syntax: Replace `asyncio.coroutine` decorator with native `async def` function definitions for coroutine creation.
Replace utf_8_sig with Standard BOM Handling: Replace `encodings.utf_8_sig` references with proper BOM handling using standard encoding methods.

Co-authored-by: naveen@gitar.ai <naveen@gitar.ai>
@gitar-bot-staging
Copy link
Author

✅ Gitar will automatically:

  • Address comments that start with 'Gitar'.
  • Look at CI failures and help fix them

⚙️ Options:

  • Disable automatic comment and CI monitoring

🐛 (Staging) Report a Bug

If you notice any bugs or poor interactions with the bot, click these links to report them:

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.

1 participant