Skip to content

Commit d72ece4

Browse files
authored
Merge pull request #11 from brian-team/cleanup
Cleanup
2 parents 4720a6c + 3a8a6a9 commit d72ece4

File tree

11 files changed

+334
-455
lines changed

11 files changed

+334
-455
lines changed

.github/workflows/pytest-ubuntu.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
run: |
2121
pdm install -G test
2222
23+
# Update output format to enable automatic inline annotations.
24+
- name: Run Ruff
25+
run: pdm run ruff check --output-format=github .
26+
2327
- name: Run tests
2428
run: |
2529
pdm run -v pytest --cov=QuantSI --cov-report lcov --doctest-modules

.gitignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,11 @@ dmypy.json
152152
# Cython debug symbols
153153
cython_debug/
154154

155-
# PyCharm
156-
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157-
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158-
# and can be added to the global gitignore or merged into this file. For a more nuclear
159-
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160-
#.idea/
155+
# VS Code
156+
.vscode/
157+
158+
# coverage
159+
coverage.*
161160

162161
# version
163162
_version.py

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.11.6
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# QuantSI
2+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
3+
[![Tests](https://github.com/brian-team/QuantSI/actions/workflows/pytest-ubuntu.yaml/badge.svg)](https://github.com/brian-team/QuantSI/actions/workflows/pytest-ubuntu.yaml)
4+
[![Coverage Status](https://coveralls.io/repos/github/brian-team/QuantSI/badge.svg?branch=main)](https://coveralls.io/github/brian-team/QuantSI?branch=main)
5+
26
Work in progress: unit system as used by the Brian2 simulator

docs_sphinx/conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('.'))
15+
16+
sys.path.insert(0, os.path.abspath("."))
1617

1718

1819
# -- Project information -----------------------------------------------------
1920

20-
project = 'QuantSI'
21-
copyright = '2024, Sorin Birchi'
22-
author = 'Sorin Birchi'
21+
project = "QuantSI"
22+
copyright = "2024, Sorin Birchi"
23+
author = "Sorin Birchi"
2324

2425
# The full version, including alpha/beta/rc tags
25-
release = '2024'
26+
release = "2024"
2627

2728

2829
# -- General configuration ---------------------------------------------------
@@ -35,22 +36,22 @@
3536
]
3637

3738
# Add any paths that contain templates here, relative to this directory.
38-
templates_path = ['_templates']
39+
templates_path = ["_templates"]
3940

4041
# List of patterns, relative to source directory, that match files and
4142
# directories to ignore when looking for source files.
4243
# This pattern also affects html_static_path and html_extra_path.
43-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
44+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4445

4546

4647
# -- Options for HTML output -------------------------------------------------
4748

4849
# The theme to use for HTML and HTML Help pages. See the documentation for
4950
# a list of builtin themes.
5051
#
51-
html_theme = 'sphinx_rtd_theme'
52+
html_theme = "sphinx_rtd_theme"
5253

5354
# Add any paths that contain custom static files (such as style sheets) here,
5455
# relative to this directory. They are copied after the builtin static files,
5556
# so a file named "default.css" will overwrite the builtin "default.css".
56-
html_static_path = ['_static']
57+
html_static_path = ["_static"]

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ test = [
3030
"pytest-xdist>=1.22.3",
3131
"pdm-backend>=2.4.3",
3232
"pytest-cov>=6.1.1",
33+
"ruff>=0.11.6",
34+
"pre-commit>=4.2.0",
3335
]
3436
docs = [
3537
"sphinx>=7",
@@ -51,4 +53,11 @@ write_to = "QuantSI/_version.py"
5153
write_template = "__version__ = '{}'"
5254

5355
[tool.pytest.ini_options]
54-
addopts = "-ra"
56+
addopts = "-ra"
57+
58+
[tool.ruff]
59+
line-length = 100
60+
target-version = "py310"
61+
62+
[tool.ruff.format]
63+
docstring-code-format = true

src/QuantSI/allunits.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,6 @@
20882088
"Mlitre",
20892089
"klitre",
20902090
"Ylitre",
2091-
"celsius" # Dummy object raising an error
20922091
]
20932092

20942093

@@ -7911,45 +7910,6 @@
79117910
]
79127911

79137912

7914-
class _Celsius:
7915-
"""
7916-
A dummy object to raise errors when ``celsius`` is used. The use of
7917-
`celsius` can lead to ambiguities when mixed with temperatures in `kelvin`,
7918-
so its use is no longer supported. See github issue #817 for details.
7919-
"""
7920-
error_text = (
7921-
"The unit 'celsius' is no longer supported to avoid"
7922-
"ambiguities when mixed with absolute temperatures defined"
7923-
"in Kelvin. Directly use 'kelvin' when you are only"
7924-
"interested in temperature differences, and add the"
7925-
"'zero_celsius' constant from the QuantSI.constants"
7926-
"module if you want to convert a temperature from Celsius to"
7927-
"Kelvin."
7928-
)
7929-
7930-
def __mul__(self, other):
7931-
raise TypeError(_Celsius.error_text)
7932-
7933-
def __rmul__(self, other):
7934-
raise TypeError(_Celsius.error_text)
7935-
7936-
def __div__(self, other):
7937-
raise TypeError(_Celsius.error_text)
7938-
7939-
def __rdiv__(self, other):
7940-
raise TypeError(_Celsius.error_text)
7941-
7942-
def __pow__(self, other):
7943-
raise TypeError(_Celsius.error_text)
7944-
7945-
def __eq__(self, other):
7946-
raise TypeError(_Celsius.error_text)
7947-
7948-
def __neq__(self, other):
7949-
raise TypeError(_Celsius.error_text)
7950-
7951-
celsius = _Celsius()
7952-
79537913
Unit.automatically_register_units = True
79547914

79557915
for unit in itertools.chain(powered_units, scaled_units, base_units):

src/QuantSI/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
34
def pytest_collection_modifyitems(config, items):
45
# List of function names whose doctests should be skipped
56
functions_to_skip = {
@@ -11,5 +12,8 @@ def pytest_collection_modifyitems(config, items):
1112
function_name = item.location[2] # The third element often contains the name in doctests
1213
# Skip specific functions' doctests
1314
if any(fn in function_name for fn in functions_to_skip):
14-
item.add_marker(pytest.mark.skip(reason="Skipping doctest for specific function due to known documentation issues"))
15-
15+
item.add_marker(
16+
pytest.mark.skip(
17+
reason="Skipping doctest for specific function due to known documentation issues"
18+
)
19+
)

0 commit comments

Comments
 (0)