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

Switched to using pyproject.toml to build environment for CI tests instead #265

Merged
merged 3 commits into from
May 9, 2024
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
3 changes: 1 addition & 2 deletions .azure-pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ steps:

- script: |
set -eux
pip install --disable-pip-version-check -r "$(Pipeline.Workspace)/src/requirements_dev.txt"
pip install --no-deps --disable-pip-version-check -e "$(Pipeline.Workspace)/src"
pip install --disable-pip-version-check -e "$(Pipeline.Workspace)/src"[cicd,clem,client,server,developer]
displayName: Install package

- script: |
Expand Down
30 changes: 8 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
repos:
# Syntax validation and some basic sanity checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Released 2023-10-09 # Prev: v4.0.1
rev: v4.5.0 # Released 2023-10-09
# rev input based on version tag format in repo (e.g. with or without 'v')
hooks:
- id: check-added-large-files
Expand Down Expand Up @@ -32,31 +32,17 @@ repos:
name: Formatting the pyproject.toml file
additional_dependencies: ["tox>=4.9"]

# Ruff for linting and formatting
# Possible replacement for isort and flake8 (https://docs.astral.sh/ruff/linter/)
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.3.5 # Released 2024-04-01
# hooks:
# # Ruff linter
# - id: ruff
# name: Running Ruff linter
# args: [--fix]
# # Ruff formatter
# - id: ruff-format
# name: Running Ruff formatter
# types_or: [python]

# Automatic source code formatting
- repo: https://github.com/psf/black
rev: 24.3.0 # Released 2024-03-15 # Prev: 22.3.0
rev: 24.3.0 # Released 2024-03-15
hooks:
- id: black
name: Formatting Python scripts according to Black
args: [--safe, --quiet]

# Automatically sort imports
- repo: https://github.com/PyCQA/isort
rev: 5.13.2 # Released 2023-12-13 # Prev: 5.12.0
rev: 5.13.2 # Released 2023-12-13
hooks:
- id: isort
name: Tidying Python imports via Isort
Expand All @@ -83,20 +69,20 @@ repos:
# Linting
- repo: https://github.com/PyCQA/flake8
# Release history: https://flake8.pycqa.org/en/latest/release-notes/index.html
rev: 7.0.0 # Released 2024-01-05 # Prev: 4.0.1
rev: 7.0.0 # Released 2024-01-05
hooks:
- id: flake8
name: Running Flake8 linter on Python files
additional_dependencies: [
# Added Flake8-pyproject plugin for .toml compatibility
"Flake8-pyproject==1.2.3",
"Flake8-pyproject==1.2.3", # Released 2023-03-21
# flake8-comprehensions URL: https://github.com/adamchainz/flake8-comprehensions
"flake8-comprehensions==3.14.0", # prev: 3.8.0
"flake8-comprehensions==3.14.0", # Released 2023-07-10
]

# Type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0 # Released 2024-03-09 # Prev: v0.910
rev: v1.9.0 # Released 2024-03-09
hooks:
- id: mypy
name: Checking types in Python scripts using MyPy
Expand All @@ -113,7 +99,7 @@ repos:

# Use Prettier to format other files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0 # Latest stable version (Released 2023-11-13)
rev: v3.1.0 # Released 2023-11-13 | Latest stable version
hooks:
- id: prettier
name: Formatting other file types according to Prettier
Expand Down
99 changes: 4 additions & 95 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ dependencies = [
"werkzeug",
]
[project.optional-dependencies]
cicd = [
"pytest-cov", # Used by Azure Pipelines for PyTest coverage reports
]
clem = [
# "matplotlib", # For visual statistical analysis of images
"readlif", # cryo-CLEM; open LIF files; part of bioio-lif
Expand All @@ -56,7 +59,6 @@ developer = [
server = [
"cryptography",
"fastapi",
"importlib_resources; python_version<'3.9'", # Not needed anymore, since dropping support for Python 3.8
"ispyb",
"jinja2",
"mysql-connector-python<=8.0.29", # ispyb 8.0.0 requires ==8.0.29
Expand Down Expand Up @@ -98,104 +100,11 @@ zip-safe = false
[tool.setuptools.packages.find]
where = ["src", "tests"]

[tool.ruff]
# Copied Ruff default recommended settings
# Files and dirs to format
include = [
"pyproject.toml",
# "setup.cfg",
"setup.py",
"src/**/*.py",
"tests/**/*.py",
]
# Exclude commonly ignored directories
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
indent-width = 4 # Format same as Black.
line-length = 88 # Format same as Black.
target-version = "py39" # Assume Python 3.9 and above

[tool.ruff.format]
docstring-code-format = false
docstring-code-line-length = "dynamic"
indent-style = "space"
line-ending = "auto"
quote-style = "double"
skip-magic-trailing-comma = false

[tool.ruff.lint]
# Currently, not all Flake8 rule codes appear to be implemented in Ruff. VSCode throws up errors for them.
# select: E901, F812, W602, W603, W604, W606
# ignore: W503
# A mix of the two need to be used for the rule codes currently desired.
select = [
"C4",
"E401",
"E711",
"E712",
"E713",
"E714",
"E721",
"E722",
"F401",
"F402",
"F403",
"F405",
"F541",
"F631",
"F632",
"F633",
"F811",
"F821",
"F822",
"F841",
"F901",
"W191",
"W291",
"W292",
"W293",
"W605",
]
ignore = [
"E203",
"E266",
"E501",
]
fixable = ["ALL"] # Allow fix for all enabled rules (when `--fix`) is provided in pre-commit.
unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" # Allow unused variables when underscore-prefixed.

[tool.isort]
profile = "black"

[tool.flake8]
# Flake8-pyproject allows .toml settings to be read into Flake8
# Flake8-pyproject allows TOML file settings to be read into Flake8
# URL: https://pypi.org/project/Flake8-pyproject/
select = [
"C4",
Expand Down
25 changes: 0 additions & 25 deletions requirements_dev.txt

This file was deleted.