Skip to content
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
19 changes: 19 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Code linting

on:
pull_request:

push:
branches:
- main

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- uses: pre-commit/action@v3.0.1
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Upload Python Package
on:
release:
types: [created]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ __pycache__
NeSST/__pycache__/
example/.ipynb_checkpoints/
*.egg-info
dist/
dist/
.vscode/

notebook/
50 changes: 50 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
additional_dependencies: [--isolated]
args: ["--maxkb=2000"]
# Add exceptions here, as a regex
exclude: ""

- id: check-json
additional_dependencies: [--isolated]

- id: check-toml
additional_dependencies: [--isolated]

- id: check-yaml
additional_dependencies: [--isolated]

- id: detect-private-key
additional_dependencies: [--isolated]

- id: end-of-file-fixer
additional_dependencies: [--isolated]

- id: trailing-whitespace
additional_dependencies: [--isolated]


- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2025.05.12
hooks:
- id: validate-pyproject

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.12
hooks:
# Run the linter.
- id: ruff
args: [--fix]
types_or: [pyi, python, jupyter]
# Ignore global python configuration for private registry and install hooks from public index
# Add for each hook
# Reference: https://github.com/pre-commit/pre-commit/issues/1454#issuecomment-1816328894
additional_dependencies: [--isolated]
# Run the formatter.
- id: ruff-format
types_or: [pyi, python, jupyter]
additional_dependencies: [--isolated]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ E-mail: ac116@ic.ac.uk

## Installation

- Easier method: Install from PyPI
- Easier method: Install from PyPI

```
pip install NeSST
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies = [

[project.optional-dependencies]
test = [
"pytest", "jupyter", "matplotlib"
"pre-commit","pytest", "jupyter", "matplotlib"
]

[tool.setuptools.package-data]
Expand Down
49 changes: 49 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Set to the lowest supported Python version.
target-version = "py311"

# Set the target line length for formatting.
line-length = 120

# Exclude a variety of commonly ignored directories.
extend-exclude = [
"example/*.ipynb"
]

src = ["."]

[lint]
# Select and/or ignore rules for linting.
# Full list of available rules: https://docs.astral.sh/ruff/rules/
extend-select = [
"B", # Flake8 bugbear
"E", # Pycodestyle errors
"F", # Pyflakes
"I", # Isort
"NPY", # Numpy
"PT", # Pytest
"RUF", # Ruff-specific rules
"UP", # Pyupgrade
"W", # Pycodestyle warnings
]
ignore = [
"NPY002", # Replace legacy `np.random.rand` call with `np.random.Generator`
"E731", # Do not assign a lambda expression, use a def
"F403", # * import used; unable to detect undefined names
"F405", # x may be undefined, or defined from star imports
"B007", # Loop control variable `i` not used within loop body
"UP006", # tuple, dict instead of Tuple, Dict
"UP015", # Unnecessary mode argument in open
"UP035", # typing.Tuple/Dict deprecated
"PT018", # Assertion should be broken down into multiple parts
"RUF002", # En dash
"B028", # No explicit `stacklevel` keyword argument found
]


[lint.pycodestyle]
max-line-length = 150 # Allow some flexibility in line lengths
max-doc-length = 150

[format]
# Enable reformatting of code snippets in docstrings.
docstring-code-format = true
4 changes: 2 additions & 2 deletions src/NeSST/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##################
from .constants import *
from .core import *
import NeSST.fitting
import NeSST.time_of_flight
from .fitting import *
from .time_of_flight import *
Loading