Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use hatch and ruff #57

Merged
merged 9 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci(dependabot):"
47 changes: 32 additions & 15 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,35 @@ on:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- main
- "v*"
pull_request: {}
workflow_dispatch:

jobs:
check-manifest:
name: Check Manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: pip install check-manifest && check-manifest

test:
name: ${{ matrix.platform }} (${{ matrix.python-version }})
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9 ,"3.10"]
python-version: [3.7, 3.8, 3.9 ,"3.10", "3.11"]
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -31,13 +44,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[testing]
pip install -e .[test]

- name: Test
run: pytest -v --color=yes --cov-report=xml --cov=useq

- name: Coverage
if: runner.os == 'Linux'
uses: codecov/codecov-action@v1

test_pymmcore:
Expand All @@ -59,7 +71,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e pymmcore-plus-from-github[testing]
pip install -e .[testing]
pip install -e .[test]

- name: Install Micro-Manager
run: python -m pymmcore_plus.install
Expand All @@ -81,16 +93,21 @@ jobs:
with:
python-version: "3.x"

- name: Install dependencies
- name: install
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel twine
git tag
pip install -U pip
pip install -U build twine
python -m build
twine check dist/*
ls -lh dist

- name: Build and publish
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python setup.py sdist bdist_wheel
twine upload dist/*

- uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
49 changes: 30 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
ci:
autoupdate_schedule: monthly
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"

default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1.3.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.124
hooks:
- id: pyupgrade
args: ["--py3-plus", "--keep-runtime-typing"]
- id: ruff
args: [--fix]

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.10.1
hooks:
- id: flake8
pass_filenames: true
- id: validate-pyproject

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v0.991
hooks:
- id: mypy
additional_dependencies: [pydantic, types-PyYAML]
additional_dependencies:
- types-PyYAML
- pydantic
files: "^src/"
126 changes: 126 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# https://peps.python.org/pep-0517/
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

# https://peps.python.org/pep-0621/
[project]
name = "useq-schema"
description = "Schema for multi-dimensional microscopy experiments"
readme = "README.md"
keywords = ["microscopy", "schema"]
requires-python = ">=3.7"
license = { text = "BSD 3-Clause License" }
authors = [{ email = "talley.lambert@gmail.com", name = "Talley Lambert" }]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Software Development",
]
dynamic = ["version"]
dependencies = ["pydantic", "numpy"]

# extras
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
[project.optional-dependencies]
yaml = ["PyYAML"]
test = ["pytest>=6.0", "pytest-cov", "PyYAML"]
dev = [
"black",
"ipython",
"mypy",
"pdbpp",
"pre-commit",
"pytest-cov",
"pytest",
"rich",
"ruff",
"PyYaml",
]

[project.urls]
Source = "https://github.com/pymmcore-plus/useq-schema"
Tracker = "https://github.com/pymmcore-plus/useq-schema/issues"

# https://hatch.pypa.io/latest/config/metadata/
[tool.hatch.version]
source = "vcs"

# https://hatch.pypa.io/latest/config/build/#file-selection
[tool.hatch.build.targets.wheel]
packages = ["src/useq"]

# https://github.com/charliermarsh/ruff
[tool.ruff]
line-length = 88
target-version = "py37"
select = [
"E", # style errors
"F", # flakes
"D", # pydocstyle
"I001", # isort
"U", # pyupgrade
# "N", # pep8-naming
# "S", # bandit
"C", # comprehensions
"B", # bugbear
"A001", # Variable shadowing a python builtin
"RUF", # ruff-specific rules
"M001", # Unused noqa directive
]
extend-ignore = [
"D100", # Missing docstring in public module
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
]

[tool.ruff.per-file-ignores]
"tests/*.py" = ["D"]

# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
filterwarnings = ["error"]

# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
files = "src/**/"
strict = true
disallow_any_generics = false
disallow_subclassing_any = false
show_error_codes = true
pretty = true


# https://coverage.readthedocs.io/en/6.4/config.html
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
"@overload",
"except ImportError",
]

# https://github.com/mgedmin/check-manifest#configuration
[tool.check-manifest]
ignore = [
".github_changelog_generator",
".pre-commit-config.yaml",
".ruff_cache/**/*",
"tests/**/*",
"tox.ini",
"setup.py"
]
95 changes: 0 additions & 95 deletions setup.cfg

This file was deleted.

Loading