diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 2bcd70e..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 88 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d7c82f..061f58d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,19 +11,19 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.7, 3.8, 3.9, "3.10"] + python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: pdm-project/setup-pdm@v3 + uses: pdm-project/setup-pdm@v4 with: python-version: ${{ matrix.python-version }} cache: true - name: Install Dependencies run: | - pdm install -dGtest + pdm sync -dGtest - name: Run Tests run: | pdm run pytest -v tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 294a3a2..330c5d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,20 +17,18 @@ jobs: - uses: actions/setup-python@v3 with: - python-version: 3.9 + python-version: '3.11' - uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20.x - run: npx changelogithub env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Build artifacts - run: | - python -m pip install build - python -m build + run: pipx run build - name: Upload to Pypi run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7de5efd --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 'v0.1.9' + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy diff --git a/pdm.lock b/pdm.lock index 36fb594..83caf67 100644 --- a/pdm.lock +++ b/pdm.lock @@ -1,81 +1,99 @@ -[[package]] -name = "atomicwrites" -version = "1.4.0" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -summary = "Atomic file writes." +# This file is @generated by PDM. +# It is not intended for manual editing. -[[package]] -name = "attrs" -version = "21.4.0" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -summary = "Classes Without Boilerplate" +[metadata] +groups = ["default", "test"] +strategy = ["cross_platform", "inherit_metadata"] +lock_version = "4.4.1" +content_hash = "sha256:969a8e7bee2c54b382fbd7fdda856dffc4a398a500b0e5e1c508d95a9cfb3bd7" [[package]] name = "colorama" version = "0.4.5" requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" summary = "Cross-platform colored terminal text." +groups = ["test"] +marker = "sys_platform == \"win32\"" +files = [ + {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, + {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, +] [[package]] -name = "importlib-metadata" -version = "4.11.4" +name = "exceptiongroup" +version = "1.2.0" requires_python = ">=3.7" -summary = "Read metadata from Python packages" -dependencies = [ - "typing-extensions>=3.6.4; python_version < \"3.8\"", - "zipp>=0.5", +summary = "Backport of PEP 654 (exception groups)" +groups = ["test"] +marker = "python_version < \"3.11\"" +files = [ + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, ] [[package]] name = "iniconfig" version = "1.1.1" summary = "iniconfig: brain-dead simple config-ini parsing" +groups = ["test"] +files = [ + {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, + {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, +] [[package]] name = "packaging" version = "21.3" requires_python = ">=3.6" summary = "Core utilities for Python packages" +groups = ["test"] dependencies = [ "pyparsing!=3.0.5,>=2.0.2", ] +files = [ + {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, + {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, +] [[package]] name = "pluggy" version = "1.0.0" requires_python = ">=3.6" summary = "plugin and hook calling mechanisms for python" -dependencies = [ - "importlib-metadata>=0.12; python_version < \"3.8\"", +groups = ["test"] +files = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, ] -[[package]] -name = "py" -version = "1.11.0" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -summary = "library with cross-python path, ini-parsing, io, code, log facilities" - [[package]] name = "pyparsing" version = "3.0.9" requires_python = ">=3.6.8" summary = "pyparsing module - Classes and methods to define and execute parsing grammars" +groups = ["test"] +files = [ + {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, + {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, +] [[package]] name = "pytest" -version = "7.1.2" +version = "7.4.4" requires_python = ">=3.7" summary = "pytest: simple powerful testing with Python" +groups = ["test"] dependencies = [ - "atomicwrites>=1.0; sys_platform == \"win32\"", - "attrs>=19.2.0", "colorama; sys_platform == \"win32\"", - "importlib-metadata>=0.12; python_version < \"3.8\"", + "exceptiongroup>=1.0.0rc8; python_version < \"3.11\"", "iniconfig", "packaging", "pluggy<2.0,>=0.12", - "py>=1.8.2", - "tomli>=1.0.0", + "tomli>=1.0.0; python_version < \"3.11\"", +] +files = [ + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, ] [[package]] @@ -83,73 +101,9 @@ name = "tomli" version = "2.0.1" requires_python = ">=3.7" summary = "A lil' TOML parser" - -[[package]] -name = "typing-extensions" -version = "4.2.0" -requires_python = ">=3.7" -summary = "Backported and Experimental Type Hints for Python 3.7+" - -[[package]] -name = "zipp" -version = "3.8.0" -requires_python = ">=3.7" -summary = "Backport of pathlib-compatible object wrapper for zip files" - -[metadata] -lock_version = "4.0" -content_hash = "sha256:d9b3b465144552c66b59c565b4aa4c4b5d11785d2c087bc0b6e9351d7f0ca6cc" - -[metadata.files] -"atomicwrites 1.4.0" = [ - {url = "https://files.pythonhosted.org/packages/2c/a0/da5f49008ec6e9a658dbf5d7310a4debd397bce0b4db03cf8a410066bb87/atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, - {url = "https://files.pythonhosted.org/packages/55/8d/74a75635f2c3c914ab5b3850112fd4b0c8039975ecb320e4449aa363ba54/atomicwrites-1.4.0.tar.gz", hash = "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"}, -] -"attrs 21.4.0" = [ - {url = "https://files.pythonhosted.org/packages/be/be/7abce643bfdf8ca01c48afa2ddf8308c2308b0c3b239a44e57d020afa0ef/attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, - {url = "https://files.pythonhosted.org/packages/d7/77/ebb15fc26d0f815839ecd897b919ed6d85c050feeb83e100e020df9153d2/attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, -] -"colorama 0.4.5" = [ - {url = "https://files.pythonhosted.org/packages/2b/65/24d033a9325ce42ccbfa3ca2d0866c7e89cc68e5b9d92ecaba9feef631df/colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, - {url = "https://files.pythonhosted.org/packages/77/8b/7550e87b2d308a1b711725dfaddc19c695f8c5fa413c640b2be01662f4e6/colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, -] -"importlib-metadata 4.11.4" = [ - {url = "https://files.pythonhosted.org/packages/35/a8/f2bd0d488c2bf932b4dda0fb91cbb687c0b1132b33130d1cfad4e2b4b963/importlib_metadata-4.11.4.tar.gz", hash = "sha256:5d26852efe48c0a32b0509ffbc583fda1a2266545a78d104a6f4aff3db17d700"}, - {url = "https://files.pythonhosted.org/packages/ab/b5/1bd220dd470b0b912fc31499e0d9c652007a60caf137995867ccc4b98cb6/importlib_metadata-4.11.4-py3-none-any.whl", hash = "sha256:c58c8eb8a762858f49e18436ff552e83914778e50e9d2f1660535ffb364552ec"}, -] -"iniconfig 1.1.1" = [ - {url = "https://files.pythonhosted.org/packages/23/a2/97899f6bd0e873fed3a7e67ae8d3a08b21799430fb4da15cfedf10d6e2c2/iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, - {url = "https://files.pythonhosted.org/packages/9b/dd/b3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3/iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, -] -"packaging 21.3" = [ - {url = "https://files.pythonhosted.org/packages/05/8e/8de486cbd03baba4deef4142bd643a3e7bbe954a784dc1bb17142572d127/packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, - {url = "https://files.pythonhosted.org/packages/df/9e/d1a7217f69310c1db8fdf8ab396229f55a699ce34a203691794c5d1cad0c/packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, -] -"pluggy 1.0.0" = [ - {url = "https://files.pythonhosted.org/packages/9e/01/f38e2ff29715251cf25532b9082a1589ab7e4f571ced434f98d0139336dc/pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, - {url = "https://files.pythonhosted.org/packages/a1/16/db2d7de3474b6e37cbb9c008965ee63835bba517e22cdb8c35b5116b5ce1/pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, -] -"py 1.11.0" = [ - {url = "https://files.pythonhosted.org/packages/98/ff/fec109ceb715d2a6b4c4a85a61af3b40c723a961e8828319fbcb15b868dc/py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, - {url = "https://files.pythonhosted.org/packages/f6/f0/10642828a8dfb741e5f3fbaac830550a518a775c7fff6f04a007259b0548/py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, -] -"pyparsing 3.0.9" = [ - {url = "https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, - {url = "https://files.pythonhosted.org/packages/71/22/207523d16464c40a0310d2d4d8926daffa00ac1f5b1576170a32db749636/pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, -] -"pytest 7.1.2" = [ - {url = "https://files.pythonhosted.org/packages/4e/1f/34657c6ac56f3c58df650ba41f8ffb2620281ead8e11bcdc7db63cf72a78/pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"}, - {url = "https://files.pythonhosted.org/packages/fb/d0/bae533985f2338c5d02184b4a7083b819f6b3fc101da792e0d96e6e5299d/pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"}, -] -"tomli 2.0.1" = [ - {url = "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {url = "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] -"typing-extensions 4.2.0" = [ - {url = "https://files.pythonhosted.org/packages/75/e1/932e06004039dd670c9d5e1df0cd606bf46e29a28e65d5bb28e894ea29c9/typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"}, - {url = "https://files.pythonhosted.org/packages/fe/71/1df93bd59163c8084d812d166c907639646e8aac72886d563851b966bf18/typing_extensions-4.2.0.tar.gz", hash = "sha256:f1c24655a0da0d1b67f07e17a5e6b2a105894e6824b92096378bb3668ef02376"}, -] -"zipp 3.8.0" = [ - {url = "https://files.pythonhosted.org/packages/80/0e/16a7ee38617aab6a624e95948d314097cc2669edae9b02ded53309941cfc/zipp-3.8.0-py3-none-any.whl", hash = "sha256:c4f6e5bbf48e74f7a38e7cc5b0480ff42b0ae5178957d564d18932525d5cf099"}, - {url = "https://files.pythonhosted.org/packages/cc/3c/3e8c69cd493297003da83f26ccf1faea5dd7da7892a0a7c965ac3bcba7bf/zipp-3.8.0.tar.gz", hash = "sha256:56bf8aadb83c24db6c4b577e13de374ccfb67da2078beba1d037c17980bf43ad"}, +groups = ["default", "test"] +marker = "python_version < \"3.11\"" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] diff --git a/pyproject.toml b/pyproject.toml index 856a437..66806c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,17 +7,17 @@ authors = [ dependencies = [ "tomli>=2.0.1; python_version < \"3.11\"", ] -requires-python = ">=3.7" +requires-python = ">=3.10" readme = "README.md" license = {text = "MIT"} dynamic = ["version"] classifiers = [ + "Topic :: Software Development :: Build Tools", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] [project.urls] @@ -31,8 +31,8 @@ pr = "onepm:pr" pun = "onepm:pun" pa = "onepm:pa" -[tool.pdm] -version = {source = "scm"} +[tool.pdm.version] +source = "scm" [tool.pdm.dev-dependencies] test = [ @@ -42,3 +42,19 @@ test = [ [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" + +[tool.ruff] +target-version = "py310" + +[tool.ruff.lint] +extend-select = [ + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "RUF", # ruff + "W", # pycodestyle + "YTT", # flake8-2020 +] + +[tool.ruff.isort] +known-first-party = ["onepm"] diff --git a/src/onepm/__init__.py b/src/onepm/__init__.py index 130e3af..37ebb75 100644 --- a/src/onepm/__init__.py +++ b/src/onepm/__init__.py @@ -1,6 +1,8 @@ +from __future__ import annotations + import os import sys -from typing import Callable, Dict, List, NoReturn, Optional, Type +from typing import Callable, NoReturn from onepm.base import PackageManager from onepm.pdm import PDM @@ -14,8 +16,9 @@ import tomli as tomllib -PACKAGE_MANAGERS: Dict[str, Type[PackageManager]] = { - p.name: p for p in [Pip, Pipenv, Poetry, PDM] +PACKAGE_MANAGERS: dict[str, type[PackageManager]] = { + p.name: p # type: ignore[type-abstract] + for p in [Pip, Pipenv, Poetry, PDM] } @@ -40,8 +43,8 @@ def determine_package_manager() -> str: return "pip" -def make_shortcut(method_name: str) -> Callable[[Optional[List[str]]], NoReturn]: - def main(args: Optional[List[str]] = None) -> NoReturn: +def make_shortcut(method_name: str) -> Callable[[list[str] | None], NoReturn]: + def main(args: list[str] | None = None) -> NoReturn: # type: ignore[misc] if args is None: args = sys.argv[1:] package_manager = PACKAGE_MANAGERS[determine_package_manager()]() diff --git a/src/onepm/base.py b/src/onepm/base.py index 40c17ad..c22c99e 100644 --- a/src/onepm/base.py +++ b/src/onepm/base.py @@ -1,16 +1,18 @@ +from __future__ import annotations + import abc import os import shutil import subprocess import sys -from typing import Iterable, List, NoReturn +from typing import Iterable, NoReturn class PackageManager(metaclass=abc.ABCMeta): name: str @staticmethod - def has_unknown_args(args: Iterable[str], expecting_values: List[str]) -> bool: + def has_unknown_args(args: Iterable[str], expecting_values: list[str]) -> bool: args_iter = iter(args) for arg in args_iter: @@ -42,14 +44,14 @@ def execute(self, *args: str) -> NoReturn: self._execute_command(command_args) @staticmethod - def _execute_command(args: List[str]) -> NoReturn: + def _execute_command(args: list[str]) -> NoReturn: if sys.platform == "win32": sys.exit(subprocess.run(args).returncode) else: os.execvp(args[0], args) @abc.abstractmethod - def get_command(self) -> List[str]: + def get_command(self) -> list[str]: pass @abc.abstractmethod diff --git a/src/onepm/pdm.py b/src/onepm/pdm.py index 101fe31..60ed0bf 100644 --- a/src/onepm/pdm.py +++ b/src/onepm/pdm.py @@ -1,4 +1,6 @@ -from typing import List, NoReturn +from __future__ import annotations + +from typing import NoReturn from onepm.base import PackageManager @@ -6,7 +8,7 @@ class PDM(PackageManager): name = "pdm" - def get_command(self) -> List[str]: + def get_command(self) -> list[str]: return [self.find_executable(self.name)] def install(self, *args: str) -> NoReturn: diff --git a/src/onepm/pip.py b/src/onepm/pip.py index d87232f..7b84a8a 100644 --- a/src/onepm/pip.py +++ b/src/onepm/pip.py @@ -1,6 +1,8 @@ +from __future__ import annotations + import os import sys -from typing import List, NoReturn, Optional +from typing import NoReturn from onepm.base import PackageManager @@ -22,23 +24,23 @@ def _ensure_virtualenv(self) -> str: except ImportError: raise Exception( "To use pip, you must activate a virtualenv or create one at `.venv`." - ) + ) from None venv.create(this_venv, with_pip=True) return this_venv - def _find_requirements_txt(self) -> Optional[str]: + def _find_requirements_txt(self) -> str | None: for filename in ["requirements.txt", "requirements.in"]: if os.path.exists(filename): return filename return None - def _find_setup_py(self) -> Optional[str]: + def _find_setup_py(self) -> str | None: for filename in ["setup.py", "pyproject.toml"]: if os.path.exists(filename): return filename return None - def get_command(self) -> List[str]: + def get_command(self) -> list[str]: venv = self._ensure_virtualenv() if sys.platform == "win32": bin_dir = "Scripts" @@ -62,7 +64,7 @@ def install(self, *args: str) -> NoReturn: "please specify packages to install." ) else: - expanded_args = ["install"] + list(args) + expanded_args = ["install", *args] self.execute(*expanded_args) def update(self, *args: str) -> NoReturn: diff --git a/src/onepm/pipenv.py b/src/onepm/pipenv.py index a848652..830fd3c 100644 --- a/src/onepm/pipenv.py +++ b/src/onepm/pipenv.py @@ -1,4 +1,6 @@ -from typing import List, NoReturn +from __future__ import annotations + +from typing import NoReturn from onepm.base import PackageManager @@ -6,7 +8,7 @@ class Pipenv(PackageManager): name = "pipenv" - def get_command(self) -> List[str]: + def get_command(self) -> list[str]: return [self.find_executable(self.name)] def install(self, *args: str) -> NoReturn: diff --git a/src/onepm/poetry.py b/src/onepm/poetry.py index 51eb7a6..1782f46 100644 --- a/src/onepm/poetry.py +++ b/src/onepm/poetry.py @@ -1,4 +1,6 @@ -from typing import List, NoReturn +from __future__ import annotations + +from typing import NoReturn from onepm.base import PackageManager @@ -6,7 +8,7 @@ class Poetry(PackageManager): name = "poetry" - def get_command(self) -> List[str]: + def get_command(self) -> list[str]: return [self.find_executable(self.name)] def install(self, *args: str) -> NoReturn: diff --git a/tests/conftest.py b/tests/conftest.py index 65fed97..a2a3e99 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import os from unittest import mock + import pytest diff --git a/tests/test_pdm.py b/tests/test_pdm.py index d044c30..d2184b0 100644 --- a/tests/test_pdm.py +++ b/tests/test_pdm.py @@ -1,6 +1,7 @@ -from onepm import pi, pa, pu, pun, pr import pytest +from onepm import pa, pi, pr, pu, pun + pytestmark = pytest.mark.usefixtures("pdm") @@ -17,7 +18,7 @@ ) def test_pdm_pi_dispatch(project, execute_args, args, expected_command): pi(args) - assert execute_args[1:] == [expected_command] + args + assert execute_args[1:] == [expected_command, *args] def test_pdm_pr(project, execute_args): diff --git a/tests/test_pip.py b/tests/test_pip.py index 0faa015..88b2857 100644 --- a/tests/test_pip.py +++ b/tests/test_pip.py @@ -2,6 +2,7 @@ import sys import pytest + from onepm import pa, pi, pr, pu, pun from onepm.pip import Pip diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 6c6885a..2f31736 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -1,6 +1,6 @@ import pytest -from onepm import pi, pa, pu, pun, pr +from onepm import pa, pi, pr, pu, pun pytestmark = pytest.mark.usefixtures("pipenv") @@ -8,7 +8,7 @@ @pytest.mark.parametrize("args", [[], ["--dev"], ["--keep-outdated", "requests"]]) def test_pipenv_pi(project, execute_args, args): pi(args) - assert execute_args[1:] == ["install"] + args + assert execute_args[1:] == ["install", *args] def test_pipenv_pr(project, execute_args): diff --git a/tests/test_poetry.py b/tests/test_poetry.py index 4a9578b..4fe21f5 100644 --- a/tests/test_poetry.py +++ b/tests/test_poetry.py @@ -1,4 +1,5 @@ import pytest + from onepm import pa, pi, pr, pu, pun pytestmark = pytest.mark.usefixtures("poetry") @@ -16,7 +17,7 @@ ) def test_poetry_pi_dispatch(project, execute_args, args, expected_command): pi(args) - assert execute_args[1:] == [expected_command] + args + assert execute_args[1:] == [expected_command, *args] def test_poetry_pu(project, execute_args): diff --git a/tests/test_utils.py b/tests/test_utils.py index eb6a6df..9fead4e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,5 @@ import pytest + from onepm import determine_package_manager