Skip to content

Commit

Permalink
Add support for Python 3.12 and drop EOL 3.6 and 3.7 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 23, 2023
1 parent 140fa51 commit 65775b1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 21 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{matrix.python-version}}
allow-prereleases: true
- name: Install CI dependencies
run: |
[[ $(uname) == Linux ]] && sudo apt-get install --yes rpm tcsh fish zsh
Expand Down
17 changes: 5 additions & 12 deletions argcomplete/_check_console_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@
import os
import sys

try:
from importlib.metadata import entry_points as importlib_entry_points
from importlib.metadata import EntryPoint
use_entry_points_backport = False
except ImportError:
from importlib_metadata import entry_points as importlib_entry_points # type:ignore
from importlib_metadata import EntryPoint # type:ignore
use_entry_points_backport = True
from importlib.metadata import entry_points as importlib_entry_points
from importlib.metadata import EntryPoint

from ._check_module import ArgcompleteMarkerNotFound, find
from typing import Iterable
Expand All @@ -37,10 +31,9 @@ def main():

entry_points : Iterable[EntryPoint] = importlib_entry_points() # type:ignore

# The importlib_metadata backport returns a tuple of entry point objects
# whereas the official library returns a SelectableGroups object
# Python 3.12+ behaves like the importlib_metadata backport
if not use_entry_points_backport and sys.version_info < (3, 12):
# Python 3.12+ returns a tuple of entry point objects
# whereas <=3.11 returns a SelectableGroups object
if sys.version_info < (3, 12):
entry_points = entry_points["console_scripts"] # type:ignore

entry_points = [ep for ep in entry_points \
Expand Down
2 changes: 1 addition & 1 deletion argcomplete/_check_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
except ImportError:
import typing as t
from collections import namedtuple
from imp import find_module
from imp import find_module # type:ignore

ModuleSpec = namedtuple("ModuleSpec", ["origin", "has_location", "submodule_search_locations"])

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "argcomplete"
description = "Bash tab completion for argparse"
readme = "README.rst"
requires-python = ">=3.6"
requires-python = ">=3.8"
license = { text = "Apache Software License" }
authors = [{ name = "Andrey Kislyuk"}, {email = "kislyuk@gmail.com" }]
maintainers = []
Expand All @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Development Status :: 5 - Production/Stable",
Expand All @@ -32,7 +33,6 @@ classifiers = [
"Topic :: System :: Shells",
"Topic :: Terminals",
]
dependencies = ["importlib-metadata >= 0.23, < 7; python_version < '3.8'"]

[project.optional-dependencies]
test = ["coverage", "pexpect", "wheel", "ruff", "mypy"]
Expand Down
4 changes: 0 additions & 4 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,25 +1370,21 @@ def _test_console_script(self, package=False, wheel=False):
self.assertEqual(self.sh.run_command(command), "arg\r\n")

@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
@unittest.skipIf(sys.version_info < (3, 8), "Skip test that fails on Python 3.7 with importlib_metadata > 4")
def test_console_script_module(self):
"""Test completing a console_script for a module."""
self._test_console_script()

@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
@unittest.skipIf(sys.version_info < (3, 8), "Skip test that fails on Python 3.7 with importlib_metadata > 4")
def test_console_script_package(self):
"""Test completing a console_script for a package."""
self._test_console_script(package=True)

@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
@unittest.skipIf(sys.version_info < (3, 8), "Skip test that fails on Python 3.7 with importlib_metadata > 4")
def test_console_script_module_wheel(self):
"""Test completing a console_script for a module from a wheel."""
self._test_console_script(wheel=True)

@unittest.skipIf(os.uname()[0] == "Darwin", "Skip test that fails on MacOS")
@unittest.skipIf(sys.version_info < (3, 8), "Skip test that fails on Python 3.7 with importlib_metadata > 4")
def test_console_script_package_wheel(self):
"""Test completing a console_script for a package from a wheel."""
self._test_console_script(package=True, wheel=True)
Expand Down

0 comments on commit 65775b1

Please sign in to comment.