diff --git a/.flake8 b/.flake8 index 01e0c2a..f295fb2 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = +ignore = # make black happy E203, W503, # self type diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b9cbca9..e91d0c7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,13 +5,12 @@ name: Python package on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: - runs-on: ubuntu-latest strategy: fail-fast: false @@ -19,22 +18,22 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index bdaab28..2f2add1 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -17,23 +17,22 @@ permissions: jobs: deploy: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d0b62d..f813fef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: # checking for syntax - id: check-yaml @@ -15,26 +15,32 @@ repos: - id: check-merge-conflict # sort python imports - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort # format f strings - repo: https://github.com/ikamensh/flynt/ - rev: "0.78" + rev: "1.0.1" hooks: - id: flynt + # pyupgrade (migrate code to newer syntax) + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.2 + hooks: + - id: pyupgrade + args: [--py39-plus] # format python code - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 + rev: 1.16.0 hooks: - id: blacken-docs additional_dependencies: [black] - repo: https://github.com/PyCQA/docformatter - rev: v1.5.1 + rev: v1.7.5 hooks: - id: docformatter additional_dependencies: @@ -42,14 +48,14 @@ repos: args: ["--in-place", "--config", "./pyproject.toml"] # format markdown, yaml, json - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.6 + rev: v4.0.0-alpha.8 hooks: - id: prettier exclude_types: [python, markdown] args: ["--print-width", "100"] # lint python code - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 # check for dead code @@ -62,17 +68,25 @@ repos: - flake8-use-fstring - flake8-docstrings - flake8-rst-docstrings + - flake8-blind-except + - flake8-requirements + - flake8-deprecated + - flake8-requirements - pep8-naming - - flake8-annotations - darglint + - flake8-warnings + - flake8-pie + - flake8-annotations + - flake8-annotations-complexity + - flake8-return # format and lint markdown - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.33.0 + rev: v0.40.0 hooks: - id: markdownlint-fix args: ["--disable", "md013,md034,md033,md036"] # static type checking - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.1.1" + rev: "v1.10.0" hooks: - id: mypy diff --git a/pyproject.toml b/pyproject.toml index d66c7e2..e6b27e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,28 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + [project] name = "nd_line" -version = "0.2.0" +version = "0.2.0" # This is the only place version should be hard coded authors = [ { name="Daniel Marshall", email="dpm42@duke.edu" }, ] description = "Interpolate points on an n-dimensional line by euclidean arc length" readme = "README.md" -license = "MIT" -requires-python = ">=3.7" +license = {file = "LICENSE"} +requires-python = ">=3.9" classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent" +] +dependencies = [ + "numpy", + "scipy" ] [project.urls] @@ -38,6 +49,5 @@ wrap-summaries = 0 wrap-descriptions = 0 in-place = true -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" +[tool.mypy] +no_namespace_packages = true diff --git a/src/nd_line/__init__.py b/src/nd_line/__init__.py index b120abf..bcdc3d8 100644 --- a/src/nd_line/__init__.py +++ b/src/nd_line/__init__.py @@ -1,3 +1,2 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- """Module for creating an n-dimensional line.""" diff --git a/src/nd_line/nd_line.py b/src/nd_line/nd_line.py index 13924e8..40e9f45 100644 --- a/src/nd_line/nd_line.py +++ b/src/nd_line/nd_line.py @@ -2,8 +2,9 @@ Copyright Daniel Marshall """ + import math -from typing import List, Optional +from typing import Optional import numpy as np from numpy import ndarray @@ -25,7 +26,7 @@ def __init__(self, points: ArrayLike) -> None: self.cumul: ndarray = np.cumsum([0.0] + alldist) self.type = 'linear' - def _lengths(self, points: ndarray) -> List[float]: + def _lengths(self, points: ndarray) -> list[float]: """Calculate the length (sum of the euclidean distance between points). :param points: numpy array of points