diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 749bb6c..0000000 --- a/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -venv/ -Dockerfile -.dockerignore -build/ -.tox/ -.pytest_cache/ -.mypy_cache/ -.github/ -*.egg-info/ diff --git a/.flake8 b/.flake8 index b8d3c6d..d9b0b18 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,7 @@ [flake8] +# E501: Allow lines to be too long (black will take care of it) +# E203: Allow whitespace before ':' extend-ignore = - W503 + E501 E203 max-line-length = 88 diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 2a1e031..b0efbd2 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,4 +1,9 @@ name: "python tests and coverage" +# Uses: +# https://github.com/actions/setup-python +# https://github.com/actions/checkout +# https://github.com/actions/download-artifact +# https://github.com/actions/upload-artifact on: pull_request: @@ -10,7 +15,7 @@ on: jobs: run-tests-and-coverage: - name: "Run Tox for tests and coverage" + name: "Run nox for tests and coverage" runs-on: "${{ matrix.os }}" strategy: fail-fast: false @@ -20,32 +25,34 @@ jobs: - "windows-latest" - "ubuntu-latest" python-version: - - "3.8" - "3.9" - "3.10" - "3.11" + - "3.12" + - "3.13" steps: - name: "Repo checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" - name: "Set up Python ${{ matrix.python-version }}" - uses: "actions/setup-python@v4" + uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" with: python-version: "${{ matrix.python-version }}" + allow-prereleases: true - - name: "Install tox" + - name: "Install nox" run: | - python -m pip install --upgrade pip tox + python -m pip install --upgrade pip nox - - name: "Run tests and coverage via tox" + - name: "Run tests and coverage via nox" run: | - tox -e py + nox --session tests_with_coverage-${{ matrix.python-version }} - name: "Save coverage artifact" - uses: "actions/upload-artifact@v3" + uses: "actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3" with: - name: "coverage-artifact" + name: "coverage-artifact-${{ matrix.os}}-${{ matrix.python-version}}" path: ".coverage.*" retention-days: 1 @@ -55,34 +62,46 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Repo checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" - name: "Set up Python" - uses: "actions/setup-python@v4" + uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" with: - python-version: "3.10" + python-version: "3.12" - - name: "Install tox" + - name: "Install nox" run: | - python -m pip install --upgrade pip tox + python -m pip install --upgrade pip nox - name: "Download coverage artifacts" - uses: actions/download-artifact@v3 + uses: "actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427" with: - name: coverage-artifact + pattern: "coverage-artifact-*" + merge-multiple: true - name: "Compile coverage data, print report" run: | - python -m tox -e coverage + nox --session coverage_combine_and_report export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") echo "TOTAL=$TOTAL" >> $GITHUB_ENV echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY - ci-success: - name: "CI steps all completed successfully" - needs: "coverage-compile" + mypy-check: + name: "mypy strict enforcement" runs-on: "ubuntu-latest" steps: - - name: "Success" + - name: "Repo checkout" + uses: "actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11" + + - name: "Set up Python" + uses: "actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c" + with: + python-version: "3.12" + + - name: "Install nox" + run: | + python -m pip install --upgrade pip nox + + - name: "Enforce strict type annotations with mypy" run: | - echo "If you are seeing this, the CI run was successful." + nox --session mypy_check diff --git a/.gitignore b/.gitignore index 324b756..0f91802 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ temp_* .env venv/ *egg-info/ -.tox/ +.nox/ .coverage .coverage.* coverage.xml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index db46f5d..3d41ed7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,10 @@ +ci: + autoupdate_schedule: monthly + repos: # Batch of helpful formatters and patterns - repo: https://github.com/pre-commit/pre-commit-hooks - rev: "v4.4.0" + rev: "v4.6.0" hooks: - id: check-json - id: check-toml @@ -10,56 +13,38 @@ repos: - id: end-of-file-fixer - id: check-docstring-first - id: debug-statements + - id: mixed-line-ending - # Adds a standard feel to import segments, adds future annotations - - repo: https://github.com/asottile/reorder-python-imports - rev: v3.10.0 + # Adds a standard feel to import segments + - repo: https://github.com/pycqa/isort + rev: 5.13.2 hooks: - - id: reorder-python-imports + - id: isort args: - - "--py37-plus" + - "--force-single-line-imports" - "--add-import" - "from __future__ import annotations" - - "--application-directories" - - ".:src" - - # Automatically upgrade syntax to newer versions - - repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 - hooks: - - id: pyupgrade - args: - - "--py38-plus" + - "--profile" + - "black" # Format code. No, I don't like everything black does either. - - repo: https://github.com/psf/black - rev: 23.3.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.4.2 hooks: - id: black - # Format docs. - - repo: https://github.com/asottile/blacken-docs - rev: 1.14.0 - hooks: - - id: blacken-docs - additional_dependencies: [black>=23.3.0] - # Flake8 for linting, line-length adjusted to match Black default - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.1.0 hooks: - id: flake8 additional_dependencies: - flake8-builtins - flake8-pep585 - args: - - "--ignore" - - "W503,E203" - - "--max-line-length" - - "88" + - pep8-naming # Type enforcement for Python - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.4.1 + rev: v1.10.1 hooks: - id: mypy diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 3d686c4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM ubuntu:focal - -ENV LANG=C.UTF-8 - -RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common -RUN add-apt-repository -y 'ppa:deadsnakes/ppa' -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3.8 python3.8-venv python3.9 python3.10 python3.11 python3.12 -RUN rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -ENV PATH=/venv/bin:$PATH -RUN python3.8 -m venv /venv -RUN python -m pip install --upgrade tox --no-cache-dir - -COPY . /src - -CMD ["tox", "-r"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 22d3721..0000000 --- a/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -.PHONY: install-dev -install-dev: - python -m pip install --upgrade --editable .[dev,test] - pre-commit install - -.PHONY: update-dev -update-dev: - python -m pip install --upgrade pip-tools - pip-compile --resolver=backtracking --no-emit-index-url requirements/requirements.in - pip-compile --resolver=backtracking --no-emit-index-url requirements/requirements-dev.in - pip-compile --resolver=backtracking --no-emit-index-url requirements/requirements-test.in - -.PHONY: upgrade-dev -upgrade-dev: - python -m pip install --upgrade pip-tools - pip-compile --resolver=backtracking --upgrade --no-emit-index-url requirements/requirements.in - pip-compile --resolver=backtracking --upgrade --no-emit-index-url requirements/requirements-dev.in - pip-compile --resolver=backtracking --upgrade --no-emit-index-url requirements/requirements-test.in - - -.PHONY: coverage -coverage: - coverage run -m pytest tests/ - coverage report -m - -.PHONY: docker-test -docker-test: - docker build -t pydocker-test . - docker run -it --rm pydocker-test - -.PHONY: build-dist -build-dist: - python -m pip install --upgrade build - python -m build - -.PHONY: clean -clean: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '__pycache__' -exec rm -rf {} + - find . -name '.mypy_cache' -exec rm -rf {} + - rm -rf .tox - rm -f coverage.xml - rm -f coverage.json - rm -rf htmlcov - rm -rf .coverage - rm -rf .coverage.* - find . -name '.pytest_cache' -exec rm -rf {} + - rm -rf dist - rm -rf build diff --git a/README.md b/README.md index c5373b2..8861f43 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Python 3.8 | 3.9 | 3.10 | 3.11](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)](https://www.python.org/downloads) +[![Python 3.9 | 3.10 | 3.11 | 3.12 | 3.13](https://img.shields.io/badge/Python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/downloads) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) @@ -42,15 +42,27 @@ fit. # Local developer installation -It is **strongly** recommended to use a virtual environment -([`venv`](https://docs.python.org/3/library/venv.html)) when working with python -projects. Leveraging a `venv` will ensure the installed dependency files will -not impact other python projects or any system dependencies. - The following steps outline how to install this repo for local development. See the [CONTRIBUTING.md](CONTRIBUTING.md) file in the repo root for information on contributing to the repo. +## Prerequisites + +### Clone repo + +```console +git clone https://github.com/[ORG NAME]/[REPO NAME] + +cd [REPO NAME] +``` + +### Virtual Environment + +Use a ([`venv`](https://docs.python.org/3/library/venv.html)), or equivalent, +when working with python projects. Leveraging a `venv` will ensure the installed +dependency files will not impact other python projects or any system +dependencies. + **Windows users**: Depending on your python install you will use `py` in place of `python` to create the `venv`. @@ -61,108 +73,82 @@ the desired version while creating the `venv`. (e.g. `python3` or `python3.8`) `python` for command line instructions. This will ensure you are using the `venv`'s python and not the system level python. ---- - -## Installation steps - -### Makefile - -This repo has a Makefile with some quality of life scripts if the system -supports `make`. Please note there are no checks for an active `venv` in the -Makefile. If you are on Windows you can install make using scoop or chocolatey. - -| PHONY | Description | -| ------------- | --------------------------------------------------------------------- | -| `install-dev` | install development/test requirements and project as editable install | -| `update-dev` | regenerate requirements-*.txt (will keep existing pins) | -| `upgrade-dev` | attempt to update all dependencies, regenerate requirements-*.txt | -| `coverage` | Run tests with coverage, generate console report | -| `docker-test` | Run coverage and tests in a docker container. | -| `build-dist` | Build source distribution and wheel distribution | -| `clean` | Deletes build, tox, coverage, pytest, mypy, cache, and pyc artifacts | - - -Clone this repo and enter root directory of repo: - -```console -$ git clone https://github.com/[ORG NAME]/[REPO NAME] -$ cd [REPO NAME] -``` - - -Create the `venv`: +### Create the `venv`: ```console -$ python -m venv venv +python -m venv venv ``` Activate the `venv`: ```console # Linux/Mac -$ . venv/bin/activate +. venv/bin/activate # Windows -$ venv\Scripts\activate +venv\Scripts\activate ``` The command prompt should now have a `(venv)` prefix on it. `python` will now call the version of the interpreter used to create the `venv` -Install editable library and development requirements: - -### With Makefile: +To deactivate (exit) the `venv`: ```console -make install-dev +deactivate ``` -### Without Makefile: +--- + +## Developer Installation Steps + +### Install editable library and development requirements ```console -$ python -m pip install --editable .[dev,test] +python -m pip install --editable .[dev,test] ``` -Install pre-commit [(see below for details)](#pre-commit): +### Install pre-commit [(see below for details)](#pre-commit) ```console -$ pre-commit install +pre-commit install ``` ---- - -## Misc Steps +### Install with nox -Run pre-commit on all files: +If you have `nox` installed with `pipx` or in the current venv you can use the +following session. This is an alternative to the two steps above. ```console -$ pre-commit run --all-files +nox -s install ``` -Run tests (quick): +--- + +## Pre-commit and nox tools + +### Run pre-commit on all files ```console -$ pytest +pre-commit run --all-files ``` -Run tests (slow): +### Run tests with coverage (quick) ```console -$ tox +nox -e coverage ``` -Build dist: +### Run tests (slow) ```console -$ python -m pip install --upgrade build - -$ python -m build +nox ``` -To deactivate (exit) the `venv`: +### Build dist ```console -$ deactivate +nox -e build ``` --- @@ -176,36 +162,16 @@ generated `requirements-*.txt` files. Once updated following the steps below, the package can be installed if needed. -### With Makefile - -To update the generated files with a dependency: +### Update the generated files with changes ```console -make update-dev +nox -e update ``` -To attempt to upgrade all generated dependencies: +### Upgrade all generated dependencies ```console -make upgrade-dev -``` - -### Without Makefile - -To update the generated files with a dependency: - -```console -pip-compile --no-emit-index-url requirements/requirements.in -pip-compile --no-emit-index-url requirements/requirements-dev.in -pip-compile --no-emit-index-url requirements/requirements-test.in -``` - -To attempt to upgrade all generated dependencies: - -```console -pip-compile --upgrade --no-emit-index-url requirements/requirements.in -pip-compile --upgrade --no-emit-index-url requirements/requirements-dev.in -pip-compile --upgrade --no-emit-index-url requirements/requirements-test.in +nox -e upgrade ``` --- @@ -216,20 +182,9 @@ pip-compile --upgrade --no-emit-index-url requirements/requirements-test.in This repo is setup with a `.pre-commit-config.yaml` with the expectation that any code submitted for review already passes all selected pre-commit checks. -`pre-commit` is installed with the development requirements and runs seemlessly -with `git` hooks. --- -## Error: File "setup.py" not found. - -If you recieve this error while installing an editible version of this project you have two choices: - -1. Update your `pip` to *at least* version 22.3.1 -2. Add the following empty `setup.py` to the project if upgrading pip is not an option +## Error: File "setup.py" not found -```py -from setuptools import setup - -setup() -``` +Update `pip` to at least version 22.3.1 diff --git a/init_template.py b/init_template.py index 996ec15..2dcd787 100644 --- a/init_template.py +++ b/init_template.py @@ -17,7 +17,7 @@ PLACEHOLDER_DIR = [Path("src/module_name/sample_data")] PYPROJECT_TARGET = Path("pyproject.toml") README_TARGET = Path("README.md") -TOX_TARGET = Path("tox.ini") +NOX_TARGET = Path("noxfile.py") ALT_FILE_DIR = Path("alt_files") REQUIREMENTS_DIR = Path("requirements") ORG = "Preocts" @@ -111,12 +111,12 @@ def replace_readme_values(data: ProjectData) -> None: README_TARGET.write_text(readme) -@bookends("Updating tox.ini values") -def replace_tox_values(data: ProjectData) -> None: - """Update tox value, replacing module_name with actual module name.""" - tox = Path(TOX_TARGET).read_text() - tox = tox.replace("module_name", data.module) - Path(TOX_TARGET).write_text(tox) +@bookends("Updating noxfile.py values") +def replace_nox_values(data: ProjectData) -> None: + """Update nox value, replacing module_name with actual module name.""" + noxfile = Path(NOX_TARGET).read_text() + noxfile = noxfile.replace("module_name", data.module) + Path(NOX_TARGET).write_text(noxfile) @bookends("Renaming src/module_name folder") @@ -132,7 +132,7 @@ def rename_module_folder(name: str) -> None: project_data = get_project_data() replace_pyproject_values(project_data) - replace_tox_values(project_data) + replace_nox_values(project_data) replace_readme_values(project_data) delete_placeholder_files() diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..1839451 --- /dev/null +++ b/noxfile.py @@ -0,0 +1,161 @@ +from __future__ import annotations + +import os +import pathlib +import shutil +import sys + +import nox + +# Control factors for finding pieces of the module +MODULE_NAME = "module_name" +TESTS_PATH = "tests" +COVERAGE_FAIL_UNDER = 50 +DEFAULT_PYTHON_VERSION = "3.12" +PYTHON_MATRIX = ["3.9", "3.10", "3.11", "3.12", "3.13"] +VENV_PATH = "venv" +REQUIREMENT_IN_FILES = [ + pathlib.Path("requirements/requirements.in"), + pathlib.Path("requirements/requirements-dev.in"), + pathlib.Path("requirements/requirements-test.in"), +] + +# What we allowed to clean (delete) +CLEANABLE_TARGETS = [ + "./dist", + "./build", + "./.nox", + "./.coverage", + "./.coverage.*", + "./coverage.json", + "./**/.mypy_cache", + "./**/.pytest_cache", + "./**/__pycache__", + "./**/*.pyc", + "./**/*.pyo", +] + + +# Define the default sessions run when `nox` is called on the CLI +nox.options.sessions = [ + "tests_with_coverage", + "coverage_combine_and_report", + "mypy_check", +] + + +@nox.session(python=PYTHON_MATRIX) +def tests_with_coverage(session: nox.Session) -> None: + """Run unit tests with coverage saved to partial file.""" + print_standard_logs(session) + + session.install(".[test]") + session.run("coverage", "run", "-p", "-m", "pytest", TESTS_PATH) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def coverage_combine_and_report(session: nox.Session) -> None: + """Combine all coverage partial files and generate JSON report.""" + print_standard_logs(session) + + fail_under = f"--fail-under={COVERAGE_FAIL_UNDER}" + + session.install(".[test]") + session.run("python", "-m", "coverage", "combine") + session.run("python", "-m", "coverage", "report", "-m", fail_under) + session.run("python", "-m", "coverage", "json") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def mypy_check(session: nox.Session) -> None: + """Run mypy against package and all required dependencies.""" + print_standard_logs(session) + + session.install(".") + session.install("mypy") + session.run("mypy", "-p", MODULE_NAME, "--no-incremental") + + +@nox.session(python=False) +def coverage(session: nox.Session) -> None: + """Generate a coverage report. Does not use a venv.""" + session.run("coverage", "erase") + session.run("coverage", "run", "-m", "pytest", TESTS_PATH) + session.run("coverage", "report", "-m") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def build(session: nox.Session) -> None: + """Build distribution files.""" + print_standard_logs(session) + + session.install("build") + session.run("python", "-m", "build") + + +@nox.session(python=False) +def install(session: nox.Session) -> None: + """Setup a development environment. Uses active venv if available, builds one if not.""" + # Use the active environement if it exists, otherwise create a new one + venv_path = os.environ.get("VIRTUAL_ENV", VENV_PATH) + + if sys.platform == "win32": + py_command = "py" + venv_path = f"{venv_path}/Scripts" + activate_command = f"{venv_path}/activate" + else: + py_command = f"python{DEFAULT_PYTHON_VERSION}" + venv_path = f"{venv_path}/bin" + activate_command = f"source {venv_path}/activate" + + if not os.path.exists(VENV_PATH): + session.run(py_command, "-m", "venv", VENV_PATH) + session.run(f"{venv_path}/python", "-m", "pip", "install", "--upgrade", "pip") + + session.run(f"{venv_path}/python", "-m", "pip", "install", "-e", ".[dev,test]") + session.run(f"{venv_path}/pre-commit", "install") + + if not os.environ.get("VIRTUAL_ENV"): + session.log(f"\n\nRun '{activate_command}' to enter the virtual environment.\n") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def update(session: nox.Session) -> None: + """Process requirement*.in files, updating only additions/removals.""" + print_standard_logs(session) + + session.install("pip-tools") + for filename in REQUIREMENT_IN_FILES: + session.run("pip-compile", "--no-emit-index-url", str(filename)) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def upgrade(session: nox.Session) -> None: + """Process requirement*.in files and upgrade all libraries as possible.""" + print_standard_logs(session) + + session.install("pip-tools") + for filename in REQUIREMENT_IN_FILES: + session.run("pip-compile", "--no-emit-index-url", "--upgrade", str(filename)) + + +@nox.session(python=False) +def clean(_: nox.Session) -> None: + """Clean cache, .pyc, .pyo, and test/build artifact files from project.""" + count = 0 + for searchpath in CLEANABLE_TARGETS: + for filepath in pathlib.Path(".").glob(searchpath): + if filepath.is_dir(): + shutil.rmtree(filepath) + else: + filepath.unlink() + count += 1 + + print(f"{count} files cleaned.") + + +def print_standard_logs(session: nox.Session) -> None: + """Reusable output for monitoring environment factors.""" + version = session.run("python", "--version", silent=True) + session.log(f"Running from: {session.bin}") + session.log(f"Running with: {version}") diff --git a/pyproject.toml b/pyproject.toml index e790f65..284d9dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,15 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools>=64", "setuptools_scm>=8"] build-backend = "setuptools.build_meta" [project] name = "module-name" -version = "0.1.0" -requires-python = ">=3.8" +requires-python = ">=3.9" description = "Module Description" readme = "README.md" license = { file = "LICENSE" } authors = [ - { email = "yourname@email.invalid", name = "[YOUR NAME]" } + { email = "yourname@email.invalid", name = "[YOUR NAME]" }, ] maintainers = [] keywords = [] @@ -18,41 +17,27 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: Implementation :: CPython" + "Programming Language :: Python :: Implementation :: CPython", ] -# Dynamic dependencies are loaded from requirements*.txt files -dynamic = ["dependencies", "optional-dependencies"] +dynamic = ["dependencies", "optional-dependencies", "version"] + +[tool.setuptools_scm] +# Purposely left empty [tool.setuptools.dynamic.dependencies] file = ["requirements/requirements.txt"] [tool.setuptools.dynamic.optional-dependencies] -dev = {file = ["requirements/requirements-dev.txt"]} -test = {file = ["requirements/requirements-test.txt"]} - -# Alertative way to specify dependencies -# dependencies = [] - -# [project.optional-dependencies] -# dev = [] -# test = [] +dev = { file = ["requirements/requirements-dev.txt"] } +test = { file = ["requirements/requirements-test.txt"] } [project.urls] homepage = "https://github.com/[ORG NAME]/[REPO NAME]" -# documentation = "" -# repository = "" -# changelog = "" # CLI scripts if needed # [project.scripts] # python-src-example = "module_name.sample:main" -# [tool.setuptools.packages.find] -# where = ["src"] # ["."] by default -# include = ["*"] # ["*"] by default -# exclude = ["tests"] # empty by default -# namespaces = true # true by default - [tool.setuptools.package-data] "module_name" = ["py.typed"] @@ -73,25 +58,15 @@ warn_unused_ignores = false [tool.coverage.run] branch = true -source = [ - "tests", -] -source_pkgs = [ - "module_name", -] +source = ["tests"] +source_pkgs = ["module_name"] [tool.coverage.paths] -source = [ - "src/", - "*/site-packages", -] -test = [ - "tests/", - "*/tests", -] +source = ["src/", "*/site-packages"] +test = ["tests/", "*/tests"] [tool.coverage.report] -exclude_lines =[ +exclude_lines = [ "pragma: no cover", "raise NotImplementedError", "if __name__ == .__main__.:", diff --git a/requirements/requirements-dev.in b/requirements/requirements-dev.in index e59aac0..8e39dbc 100644 --- a/requirements/requirements-dev.in +++ b/requirements/requirements-dev.in @@ -13,3 +13,4 @@ mypy flake8 flake8-builtins flake8-pep585 +pep8-naming diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 50da1dc..860df5c 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,32 +1,33 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --no-emit-index-url --resolver=backtracking requirements/requirements-dev.in +# pip-compile --no-emit-index-url requirements/requirements-dev.in # -black==23.3.0 +black==24.2.0 # via -r requirements/requirements-dev.in -cfgv==3.3.1 +cfgv==3.4.0 # via pre-commit -click==8.1.3 +click==8.1.7 # via black -distlib==0.3.6 +distlib==0.3.8 # via virtualenv -filelock==3.12.2 +filelock==3.13.1 # via virtualenv -flake8==6.0.0 +flake8==7.0.0 # via # -r requirements/requirements-dev.in # flake8-builtins -flake8-builtins==2.1.0 + # pep8-naming +flake8-builtins==2.2.0 # via -r requirements/requirements-dev.in flake8-pep585==0.1.7 # via -r requirements/requirements-dev.in -identify==2.5.24 +identify==2.5.35 # via pre-commit mccabe==0.7.0 # via flake8 -mypy==1.4.1 +mypy==1.9.0 # via -r requirements/requirements-dev.in mypy-extensions==1.0.0 # via @@ -34,31 +35,27 @@ mypy-extensions==1.0.0 # mypy nodeenv==1.8.0 # via pre-commit -packaging==23.1 +packaging==24.0 # via black -pathspec==0.11.1 +pathspec==0.12.1 # via black -platformdirs==3.8.0 +pep8-naming==0.14.1 + # via -r requirements/requirements-dev.in +platformdirs==4.2.0 # via # black # virtualenv -pre-commit==3.3.3 +pre-commit==3.6.2 # via -r requirements/requirements-dev.in -pycodestyle==2.10.0 +pycodestyle==2.11.1 # via flake8 -pyflakes==3.0.1 +pyflakes==3.2.0 # via flake8 -pyyaml==6.0 +pyyaml==6.0.1 # via pre-commit -tomli==2.0.1 - # via - # black - # mypy -typing-extensions==4.7.0 - # via - # black - # mypy -virtualenv==20.23.1 +typing-extensions==4.10.0 + # via mypy +virtualenv==20.25.1 # via pre-commit # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/requirements-test.in b/requirements/requirements-test.in index a8450e2..bb87f28 100644 --- a/requirements/requirements-test.in +++ b/requirements/requirements-test.in @@ -1,4 +1,4 @@ -# Testing Requirements - pytest, tox, etc. +# Testing Requirements # ---------------------------------------- # Ensure to set PIP_INDEX_URL to the correct value for your environment # This is the URL to the Artifactory instance that hosts the Python packages (default: pypi.org) @@ -11,4 +11,4 @@ pytest pytest-randomly coverage -tox +nox diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index deda8d6..d5b288e 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -1,58 +1,36 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --no-emit-index-url --resolver=backtracking requirements/requirements-test.in +# pip-compile --no-emit-index-url requirements/requirements-test.in # -cachetools==5.3.1 - # via tox -chardet==5.1.0 - # via tox -colorama==0.4.6 - # via tox -coverage==7.2.7 +argcomplete==3.2.3 + # via nox +colorlog==6.8.2 + # via nox +coverage==7.4.3 # via -r requirements/requirements-test.in -distlib==0.3.6 +distlib==0.3.8 + # via virtualenv +filelock==3.13.1 # via virtualenv -exceptiongroup==1.1.1 - # via pytest -filelock==3.12.2 - # via - # tox - # virtualenv -importlib-metadata==6.7.0 - # via pytest-randomly iniconfig==2.0.0 # via pytest -packaging==23.1 - # via - # pyproject-api - # pytest - # tox -platformdirs==3.8.0 - # via - # tox - # virtualenv -pluggy==1.2.0 +nox==2024.3.2 + # via -r requirements/requirements-test.in +packaging==24.0 # via + # nox # pytest - # tox -pyproject-api==1.5.2 - # via tox -pytest==7.4.0 +platformdirs==4.2.0 + # via virtualenv +pluggy==1.4.0 + # via pytest +pytest==8.1.1 # via # -r requirements/requirements-test.in # pytest-randomly -pytest-randomly==3.12.0 - # via -r requirements/requirements-test.in -tomli==2.0.1 - # via - # pyproject-api - # pytest - # tox -tox==4.6.3 +pytest-randomly==3.15.0 # via -r requirements/requirements-test.in -virtualenv==20.23.1 - # via tox -zipp==3.15.0 - # via importlib-metadata +virtualenv==20.25.1 + # via nox diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 25afd67..48a4bfc 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile --no-emit-index-url --resolver=backtracking requirements/requirements.in +# pip-compile --no-emit-index-url requirements/requirements.in # diff --git a/src/module_name/sample.py b/src/module_name/sample.py index 06e66dd..8f0589b 100644 --- a/src/module_name/sample.py +++ b/src/module_name/sample.py @@ -1,4 +1,5 @@ """This is just a sample file""" + from __future__ import annotations diff --git a/tests/test_sample.py b/tests/test_sample.py index e68214b..c748611 100644 --- a/tests/test_sample.py +++ b/tests/test_sample.py @@ -1,4 +1,5 @@ """Tests for sample""" + from __future__ import annotations import pytest diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 653e173..0000000 --- a/tox.ini +++ /dev/null @@ -1,23 +0,0 @@ -[tox] -envlist = py38,py39,py310,py311,py312,coverage,mypy -skip_missing_interpreters = true -isolated_build = True - -[testenv] -deps = - .[test] -commands = - coverage run -p -m pytest tests/ - -[testenv:coverage] -depends = py38,py39,py310,py311,py312 -commands = - python -m coverage combine - python -m coverage report -m --fail-under=50 - python -m coverage json - -[testenv:mypy] -deps = - mypy -commands = - mypy -p module_name --no-incremental