Skip to content

Commit 8cde825

Browse files
committed
use ruff
1 parent 947b469 commit 8cde825

File tree

6 files changed

+41
-29
lines changed

6 files changed

+41
-29
lines changed

.github/workflows/wheels.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,42 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@v4
24-
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v5
24+
- name: Install uv and set the python version
25+
uses: astral-sh/setup-uv@v4
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install dependencies
2929
run: |
30-
python -m pip install --upgrade pip
31-
pip install flake8 pytest black "black[jupyter]"
32-
pip install build
33-
- name: Check
30+
uv venv
31+
uv run python -m compileall -f arc/*.py
32+
- name: Lint and format check
3433
run: |
3534
# stop the build if there are Python syntax errors or undefined names
36-
flake8 --version
37-
flake8 . --count --show-source --statistics
38-
black --version
39-
black -l 80 . --check
40-
python -m compileall -f arc/*.py
35+
uvx ruff check
36+
uv run python -m compileall -f arc/*.py
37+
- name: Typing check
38+
run: |
39+
uv run mypy .
4140
4241
function_test:
4342
name: Basic test suite
4443
runs-on: ubuntu-latest
4544
needs: [format_test]
4645
steps:
4746
- uses: actions/checkout@v4
48-
- name: Set up Python 3.12
49-
uses: actions/setup-python@v5
47+
- name: Install uv and set the python version
48+
uses: astral-sh/setup-uv@v4
5049
with:
51-
python-version: 3.12
50+
python-version: ${{ matrix.python-version }}
5251
- name: Setup ARC
5352
run: |
54-
pip install .
55-
pip install pytest coverage
56-
pytest --version
53+
uv venv
5754
- name: Run tests
5855
run:
59-
coverage run -m pytest -s -v
56+
uv run coverage run -m pytest -s -v
6057
- name: Coverage report
6158
run:
62-
coverage report -m
59+
uv run coverage report -m
6360

6461
build_wheels:
6562
name: Build wheels on ${{ matrix.os }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ dist/
1515
/doc/divalent_atom_data
1616
/doc/generated
1717
/doc/_static
18+
.coverage

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

arc/alkali_atom_functions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def _parseLevelsFromNIST(self, fileData: str):
674674
f.close()
675675
return levels
676676

677-
def _addEnergy(self, n: int, l: float, j: float, energyNIST: float):
677+
def _addEnergy(self, n: int, l: int, j: float, energyNIST: float):
678678
"""
679679
Adding energy levels
680680
@@ -2886,6 +2886,7 @@ def getSphericalMatrixElementHFStoFS(
28862886
for f2 in np.arange(
28872887
max(self.I - j2, abs(mf2), f1 - 1), 1 + min(self.I + j2, f1 + 1)
28882888
):
2889+
f2 = cast(float, f2)
28892890
# Enforce Triangle Rule
28902891
if abs(j2 - self.I) <= f2:
28912892
# CG multiplied by <j1 f1 mf1|er_q|j2 f2 mf2> in units of <j1 || er || j2 >
@@ -3160,6 +3161,7 @@ def getBranchingRatio(
31603161
UsedModulesARC.hyperfine = True
31613162
b = 0.0
31623163
for q in np.arange(-1, 2):
3164+
q = cast(int, q)
31633165
b += (
31643166
self.getSphericalDipoleMatrixElement(fg, mfg, fe, mfe, q) ** 2
31653167
* self._reducedMatrixElementFJ(jg, fg, je, fe) ** 2
@@ -3869,9 +3871,9 @@ def NumerovBack(
38693871

38703872
br = divergencePoint
38713873
while br > 0:
3872-
rad[br] = rad[br + 1] - step
3873-
sol[br] = 0
3874-
br -= 1
3874+
rad[br] = rad[br + 1] - step # type: ignore
3875+
sol[br] = 0 # type: ignore
3876+
br -= 1 # type: ignore
38753877

38763878
# convert R(r)*r^{3/4} to R(r)*r
38773879
sol = np.multiply(sol, np.sqrt(rad))

doc/contribute.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ Finally, this is the naming convention. of the original package. For consistency
7474
Code format
7575
-----------
7676

77-
Please run ``black`` in the repository folder fixing line length to 80 characters::
77+
Please run install `uv` and run linter::
7878

79-
black -l 80 .
79+
pip install uv
80+
uvx ruff format
81+
uvx ruff check
8082

81-
And then run linter
83+
and resolve any errors that appear there before submitting code.
8284

83-
flake8 .
85+
Optionally also check typing::
8486

85-
and resolve any erros that appear there before submitting code.
87+
uv pip install mypy
88+
uv run mypy .

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,19 @@ Repository = "https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator"
7474
Documentation = "https://arc-alkali-rydberg-calculator.readthedocs.io/en/latest/"
7575
Download = "https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator/archive/refs/tags/v3.6.0.tar.gz"
7676

77+
[dependency-groups]
78+
dev = [
79+
"cibuildwheel>=2.22.0",
80+
"coverage>=7.6.1",
81+
"mypy>=1.14.0",
82+
"pytest>=8.3.4",
83+
]
84+
7785
[tool.cibuildwheel]
7886
skip = ["*-win32", "*-manylinux_i686", "*-musllinux_i686" ,"pp*"]
7987

8088
[tool.mypy]
81-
disable_error_code = ["import-untyped"]
89+
disable_error_code = ["import-untyped", "import-not-found"]
8290

8391
[tool.ruff]
8492
# Exclude a variety of commonly ignored directories.

0 commit comments

Comments
 (0)