diff --git a/.github/actions/setup_python/action.yml b/.github/actions/setup_python/action.yml index 1ff0592..757f112 100644 --- a/.github/actions/setup_python/action.yml +++ b/.github/actions/setup_python/action.yml @@ -5,7 +5,7 @@ inputs: python_version: description: "Version of Python to use" required: false - default: "3.7" + default: "3.8" python_packages: description: "Python packages to install" required: false diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index baee069..da831e4 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -13,10 +13,10 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python uses: ./.github/actions/setup_python - - name: ๐Ÿ” Lint - run: | - ruff check --output-format github . - mypy . + - name: Lint (ruff) + run: ruff check --output-format github . + - name: Lint (mypy) + run: mypy . format: name: ๐ŸŽจ Format runs-on: ubuntu-latest @@ -24,16 +24,16 @@ jobs: - uses: actions/checkout@v4 - name: Setup Python uses: ./.github/actions/setup_python - - name: ๐ŸŽจ Format - run: | - python -m black --check --diff . - python -m isort --check --diff . + - name: Format (black) + run: python -m black --check --diff . + - name: Format (isort) + run: python -m isort --check --diff . test: name: ๐Ÿงช Tests runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v4 - name: Setup Python diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e986845..0b5013d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: black - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) @@ -34,7 +34,7 @@ repos: - id: mypy args: [--strict] additional_dependencies: [ - "Click >=8.0.4,<9.0.0", - "types-PyYAML >=6.0.0", - "pytest >=7.2.0,<8.0.0" + "Click ~=8.1.7", + "types-PyYAML ~=6.0.0", + "pytest ~=7.4.3" ] diff --git a/lnmc.py b/lnmc.py index 66b6330..db2498b 100644 --- a/lnmc.py +++ b/lnmc.py @@ -168,7 +168,7 @@ def echo( def yaml_read(yaml_file: Path) -> DirectoriesDict: """Read the YAML file and return a dictionary.""" - with open(yaml_file, "r", encoding="utf-8") as stream: + with yaml_file.open(encoding="utf-8") as stream: result = yaml.safe_load(stream.read()) if not isinstance(result, dict): raise cli.UsageError( diff --git a/pyproject.toml b/pyproject.toml index 9465134..3d04cf3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools >= 68.0.0", "wheel"] +requires = ["setuptools >= 69.0.3", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -18,7 +18,6 @@ classifiers = [ "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -26,10 +25,10 @@ classifiers = [ "Topic :: System :: Systems Administration", "Topic :: Utilities", ] -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ - "Click >=8.0.4,<9.0.0", - "PyYAML >=6.0.0,<7.0.0" + "Click ~=8.1.7", + "PyYAML ~=6.0.0" ] dynamic = ["version"] @@ -40,14 +39,14 @@ Documentation = "https://github.com/LuqueDaniel/lnmc/blob/master/README.md" [project.optional-dependencies] dev = [ - "pre-commit ==2.21.0", - "black ==23.3.0", - "isort >=5.11.5,<5.12.0", # 5.12.0+ requires Python 3.8+ + "pre-commit ==3.5.0", + "black ==23.12.1", + "isort ~=5.13.2", "ruff >=0.1.9", - "mypy ~=1.4.1", + "mypy ~=1.8.0", "pytest ~=7.4.3", "pytest-cov ~=4.1.0", - "types-PyYAML >=6.0.0", + "types-PyYAML ~=6.0.0", ] [project.scripts] @@ -58,21 +57,35 @@ py-modules = ["lnmc"] dynamic = {version = {attr = "lnmc.__version__"}} [tool.black] -target-version = ["py37"] +target-version = ["py38"] [tool.isort] profile = "black" -known_third_party = ["click", "pytest", "setuptools", "yaml"] +known_third_party = ["click", "pytest", "yaml"] [tool.pytest.ini_options] addopts = "-vvs --cov=lnmc" [tool.ruff] -target-version = "py37" +target-version = "py38" src = ["."] fix = false line-length = 88 # its default -select = ["F", "E", "W", "C", "B", "N"] +select = [ + "F", # Pyflakes + "E", # pycodestyle (E, W) + "W", + "B", # flake8-bugbear + "N", # pep8-naming + "UP", # pyupgrade + "S", # flake8-bandit + "C4", # flake8-comprehensions + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib +] + +[tool.ruff.extend-per-file-ignores] +"*_test.py" = ["S101"] # Bandit use of asset in test files [tool.mypy] strict = true diff --git a/tests/conftest.py b/tests/conftest.py index 7af2d45..8af5982 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,7 +15,7 @@ YAML_TEST_FILE = Path("tests/test.yaml") -@pytest.fixture(scope="function") +@pytest.fixture() def filesystem_actions(tmp_path: Path) -> FileSystemActions: """Instantiate a lnmc.FileSystemActions object and return it. @@ -28,7 +28,7 @@ def filesystem_actions(tmp_path: Path) -> FileSystemActions: return FileSystemActions(tmp_path, DST, verbose=True) -@pytest.fixture(scope="function") +@pytest.fixture() def create_test_tree(tmp_path: Path) -> Generator[None, None, None]: """Create a test directory tree based on the content of YAML_TEST_FILE.""" directories = yaml_read(YAML_TEST_FILE) @@ -48,7 +48,7 @@ def create_test_tree(tmp_path: Path) -> Generator[None, None, None]: shutil.rmtree(DST) -@pytest.fixture(scope="function") +@pytest.fixture() def create_test_file( tmp_path: Path, file_path: str = "dir/file.txt" ) -> Generator[PathPair, None, None]: