diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index fb9b59d..d85bcde 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -14,10 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Set up cache uses: actions/cache@v2 with: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 56d3cb1..a6efbc9 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Pip Update run: | make -s update-pip diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ac396af..27bc5d0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,30 +9,49 @@ on: - main jobs: - test: + # test: + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v3 + # - name: Disable Logger Outputs + # run: | + # sed -i "s/log_cli = true/log_cli = false/" pyproject.toml + # - name: Install the latest version of rye + # uses: eifinger/setup-rye@v1 + # with: + # enable-cache: true + # cache-prefix: 'rye-venv-cache' + # - name: Install the Project with Test Dependencies + # run: | + # rye sync --no-lock + # - name: Test the Project + # run: | + # python -m pytest -n auto + + test_matrix: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - # os: [ubuntu-20.04, ubuntu-22.04] - runs-on: ubuntu-22.04 + python-version: ['3.11', '3.12'] + os: [ubuntu-22.04] # windows-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - name: Disable Logger Outputs run: | sed -i "s/log_cli = true/log_cli = false/" pyproject.toml - - name: Pip Update + - name: Install the latest version of rye + uses: eifinger/setup-rye@v1 + with: + enable-cache: true + cache-prefix: 'rye-venv-cache' + - name: Pin Python Version - ${{ matrix.python-version }} run: | - make -s update-pip + rye pin ${{ matrix.python-version }} - name: Install the Project with Test Dependencies run: | - make -s install-test - # - name: Show dependencies - # run: python -m pip list + rye sync --no-lock - name: Test the Project - run: make -s test-parallel + run: | + python -m pytest -n auto # - name: Publish code coverage # uses: codecov/codecov-action@v3 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 82555e6..31ce050 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: - package - doc -image: python:3.10 +image: python:3.11 lint: stage: lint @@ -26,7 +26,7 @@ tests: echo "*********** Pip Update ***********" make -s update-pip echo "*********** Install the Project with Test Dependencies ***********" - make -s install-test + make -s install echo "*********** Test the Project ***********" make -s test-parallel only: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f8cce7..2e3862a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: python-use-type-annotations - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.3 + rev: v0.1.11 hooks: # Run the Ruff linter. - id: ruff diff --git a/.python-version b/.python-version index 09dcc78..375f5ca 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.10.11 +3.11.6 diff --git a/.vscode/settings.json b/.vscode/settings.json index c169afb..64ee0ab 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,8 +3,8 @@ "editor.formatOnSave": true, "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { - // "source.fixAll": true, - "source.organizeImports.ruff": true, + // "source.fixAll": "always", + "source.organizeImports.ruff": "explicit", }, "editor.rulers": [ { @@ -22,4 +22,10 @@ "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, // "python.testing.pytestArgs": [], + "notebook.formatOnSave.enabled": true, + "notebook.codeActionsOnSave": { + // "source.fixAll.ruff": "always", + "source.organizeImports.ruff": "explicit", + }, + "evenBetterToml.formatter.reorderKeys": true, } diff --git a/Makefile b/Makefile index 78ff5f6..8c4fa16 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SHELL=/bin/bash ROOT_DIR=python-template PACKAGE=src/python_template PYTHON = python -PYTHON_VERSION=3.10 +PYTHON_VERSION=3.11 DOC_DIR=./docs TEST_DIR=./tests TEST_MARKER=placeholder @@ -46,6 +46,7 @@ install-base: ## Installs only package dependencies rye sync --no-dev --no-lock install: ## Installs the development version of the package + $(MAKE) install-rye rye sync --no-lock $(MAKE) install-precommit @@ -59,7 +60,7 @@ install-precommit: ## Install pre-commit hooks pre-commit install install-lint: - pip install ruff==0.1.3 + pip install ruff==0.1.11 install-doc: pip install mkdocs mkdocs-material mkdocstrings[python] diff --git a/docker/Dockerfile b/docker/Dockerfile index b7722b2..4382683 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -ARG PYTHON_BASE_IMAGE=3.10-slim-bookworm +ARG PYTHON_BASE_IMAGE=3.11-slim-bookworm ARG APP_NAME=python_template # diff --git a/docs/poetry.md b/docs/poetry.md index de91047..d0dbd36 100644 --- a/docs/poetry.md +++ b/docs/poetry.md @@ -43,7 +43,7 @@ poetry add - Add package with specific version constraint ```bash -poetry add ruff==0.1.3 +poetry add ruff==0.1.11 ``` - Add package from git diff --git a/pyproject.toml b/pyproject.toml index 8fb3252..2855598 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ version = "0.0.0" description = "Python Template" # NOTE: Overwrites .python-version -# requires-python = ">=3.9,<3.12" +# requires-python = ">=3.11,<3.13" authors = [ {name = "template", email = "template@github.com"}, @@ -29,9 +29,8 @@ classifiers = [ "Operating System :: POSIX", "Operating System :: Unix", "Operating System :: MacOS", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dependencies = [] @@ -40,7 +39,7 @@ dependencies = [] managed = true dev-dependencies = [ "pre-commit", - "ruff==0.1.3", + "ruff==0.1.11", "mypy", "scalene~=1.5.21.2", ## DOCS @@ -89,7 +88,7 @@ log_cli_date_format = "%Y-%m-%d %H:%M:%S" [tool.ruff] target-version = "py310" -# required-version = "0.1.3" +# required-version = "0.1.11" line-length = 88 src = ["src"] select = [ @@ -119,6 +118,7 @@ unfixable = [ ] ignore-init-module-imports = true # ignore = [] +extend-include = ["*.ipynb"] extend-ignore = [ "E501", # Line too long, handled by ruff formatter "D107", # "Missing docstring in __init__", diff --git a/requirements-dev.lock b/requirements-dev.lock index f96de95..dd42a5a 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -7,66 +7,64 @@ # all-features: false -e file:. -babel==2.13.1 -certifi==2023.7.22 +babel==2.14.0 +certifi==2023.11.17 cfgv==3.4.0 -charset-normalizer==3.3.1 +charset-normalizer==3.3.2 click==8.1.7 cloudpickle==3.0.0 colorama==0.4.6 -coverage==7.3.2 -distlib==0.3.7 -exceptiongroup==1.1.3 +coverage==7.4.0 +distlib==0.3.8 execnet==2.0.2 -filelock==3.12.4 +filelock==3.13.1 ghp-import==2.1.0 -griffe==0.36.7 -identify==2.5.30 -idna==3.4 +griffe==0.38.1 +identify==2.5.33 +idna==3.6 iniconfig==2.0.0 jinja2==3.1.2 -markdown==3.5 +markdown==3.5.1 markdown-it-py==3.0.0 markupsafe==2.1.3 mdurl==0.1.2 mergedeep==1.3.4 mkdocs==1.5.3 mkdocs-autorefs==0.5.0 -mkdocs-material==9.4.6 -mkdocs-material-extensions==1.3 -mkdocstrings==0.23.0 -mkdocstrings-python==1.7.3 -mypy==1.6.1 +mkdocs-material==9.5.3 +mkdocs-material-extensions==1.3.1 +mkdocstrings==0.24.0 +mkdocstrings-python==1.7.5 +mypy==1.8.0 mypy-extensions==1.0.0 nodeenv==1.8.0 packaging==23.2 paginate==0.5.6 -pathspec==0.11.2 -platformdirs==3.11.0 +pathspec==0.12.1 +platformdirs==4.1.0 pluggy==1.3.0 -pre-commit==3.5.0 -psutil==5.9.6 -pygments==2.16.1 -pymdown-extensions==10.3.1 +pre-commit==3.6.0 +psutil==5.9.7 +pygments==2.17.2 +pymdown-extensions==10.7 pynvml==11.4.1 -pytest==7.4.2 +pytest==7.4.4 pytest-cov==4.1.0 -pytest-rerunfailures==12.0 -pytest-xdist==3.3.1 +pytest-rerunfailures==13.0 +pytest-xdist==3.5.0 python-dateutil==2.8.2 pyyaml==6.0.1 pyyaml-env-tag==0.1 -regex==2023.10.3 +regex==2023.12.25 requests==2.31.0 -rich==13.6.0 -ruff==0.1.3 +rich==13.7.0 +ruff==0.1.11 scalene==1.5.21.4 six==1.16.0 -tomli==2.0.1 -typing-extensions==4.8.0 -urllib3==2.0.7 -virtualenv==20.24.6 +typing-extensions==4.9.0 +urllib3==2.1.0 +virtualenv==20.25.0 watchdog==3.0.0 -wheel==0.41.2 +wheel==0.42.0 # The following packages are considered to be unsafe in a requirements file: -setuptools==68.2.2 +setuptools==69.0.3 diff --git a/src/python_template/__init__.py b/src/python_template/__init__.py index 8848fb3..fd1b2ab 100644 --- a/src/python_template/__init__.py +++ b/src/python_template/__init__.py @@ -1,5 +1,5 @@ """Python template package.""" -import pkg_resources # type: ignore +from importlib.metadata import version # Fetches the version of the package as defined in pyproject.toml -__version__ = pkg_resources.get_distribution("python_template").version +__version__ = version("python_template") diff --git a/src/python_template/placeholder.py b/src/python_template/placeholder.py index f34b86b..58f70b1 100644 --- a/src/python_template/placeholder.py +++ b/src/python_template/placeholder.py @@ -22,10 +22,8 @@ - `divide(a, b)` - Returns the quotient of two numbers. """ -from typing import Union - -def add(a: Union[float, int], b: Union[float, int]) -> float: +def add(a: float | int, b: float | int) -> float: """Compute and return the sum of two numbers. Examples: @@ -44,7 +42,7 @@ def add(a: Union[float, int], b: Union[float, int]) -> float: return float(a + b) -def subtract(a: Union[float, int], b: Union[float, int]) -> float: +def subtract(a: float | int, b: float | int) -> float: """Compute and return the substaction of two numbers. Examples: @@ -63,7 +61,7 @@ def subtract(a: Union[float, int], b: Union[float, int]) -> float: return float(a - b) -def multiply(a: Union[float, int], b: Union[float, int]) -> float: +def multiply(a: float | int, b: float | int) -> float: """Compute and return the multiplication of two numbers. Examples: @@ -82,7 +80,7 @@ def multiply(a: Union[float, int], b: Union[float, int]) -> float: return float(a * b) -def divide(a: Union[float, int], b: Union[float, int]) -> float: +def divide(a: float | int, b: float | int) -> float: """Compute and return the division of two numbers. Examples: