Skip to content

Commit efc1f76

Browse files
Use ruff (#403)
Close #400. - [ ] Decide what to do about `spec-0007/transition_to_rng.py` (ruff is complaining)
1 parent b057d68 commit efc1f76

7 files changed

Lines changed: 15 additions & 21 deletions

File tree

.pre-commit-config.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,19 @@ repos:
1616
- id: check-toml
1717
- id: check-added-large-files
1818

19-
- repo: https://github.com/psf/black
20-
rev: 8a737e727ac5ab2f1d4cf5876720ed276dc8dc4b # frozen: 25.1.0
21-
hooks:
22-
- id: black
23-
2419
- repo: https://github.com/rbubley/mirrors-prettier
25-
rev: 787fb9f542b140ba0b2aced38e6a3e68021647a3 # frozen: v3.5.3
20+
rev: 5ba47274f9b181bce26a5150a725577f3c336011 # frozen: v3.6.2
2621
hooks:
2722
- id: prettier
2823
files: \.(md|yml|yaml)
2924
args: [--prose-wrap=preserve]
3025

31-
- repo: https://github.com/asottile/pyupgrade
32-
rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: 4cbc74d53fe5634e58e0e65db7d28939c9cec3f7 # frozen: v0.12.7
3328
hooks:
34-
- id: pyupgrade
35-
args: [--py38-plus]
29+
- id: ruff
30+
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
31+
- id: ruff-format
3632

3733
- repo: https://github.com/codespell-project/codespell
3834
rev: "63c8f8312b7559622c0d82815639671ae42132ac" # frozen: v2.4.1

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.ruff]
2+
target-version = "py313"
3+
exclude = ["spec-0007/transition_to_rng.py"]

spec-0000/SPEC0_versions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import datetime, timedelta
44

55
import pandas as pd
6-
from packaging.version import Version
6+
from packaging.version import Version, InvalidVersion
77

88

99
py_releases = {
@@ -58,8 +58,8 @@ def get_release_dates(package, support_time=plus24):
5858
ver = f["filename"].split("-")[1]
5959
try:
6060
version = Version(ver)
61-
except:
62-
continue
61+
except InvalidVersion as e:
62+
print(f"Error: '{ver}' is an invalid version. Reason: {e}")
6363

6464
if version.is_prerelease or version.micro != 0:
6565
continue
@@ -68,8 +68,8 @@ def get_release_dates(package, support_time=plus24):
6868
for format in ["%Y-%m-%dT%H:%M:%S.%fZ", "%Y-%m-%dT%H:%M:%SZ"]:
6969
try:
7070
release_date = datetime.strptime(f["upload-time"], format)
71-
except:
72-
pass
71+
except ValueError as e:
72+
print(f"Error parsing invalid date: {e}")
7373

7474
if not release_date:
7575
continue
@@ -168,7 +168,7 @@ def pad_table(table):
168168
if not width:
169169
continue
170170
line += f"| {str.ljust(entry, width)} "
171-
line += f"|"
171+
line += "|"
172172
padded_table.append(line)
173173

174174
return padded_table

spec-0002/index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ A successful prototype implementation of this SPEC is already integrated into [N
5858

5959
2. Backend Requirements
6060
To ensure that a backend is compatible with NetworkX, it must adhere to specific structural requirements:
61-
6261
1. The backend must implement a class that behaves like the `nx.Graph` object, including an attribute `__networkx_backend__` that identifies the backend.
6362

6463
2. The backend should provide `convert_from_nx` and `convert_to_nx` methods to facilitate the conversion between NetworkX graphs and the backend's graph representation.
@@ -70,7 +69,6 @@ A successful prototype implementation of this SPEC is already integrated into [N
7069
pytest --pyargs networkx
7170

7271
4. Currently, the following ways exist in NetworkX to dispatch a function call to a backend:
73-
7472
1. Type-based dispatching
7573
```py
7674
H = nx_parallel.ParallelGraph(G)

spec-0005/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ and other ancillary information as needed.
8585
- Recommend that CI running against PRs be expected to pass--if it fails, it should be important
8686

8787
- Schedule regular runs of CI against nightlies/pre-releases
88-
8988
- Good for other checks that don't need to run on every PR
9089
- Could use for pins
9190
- Can use labels to trigger additional runs of "exotic" jobs

spec-0006/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ This document deals with the situation in which that is not possible, and secret
5959
This ensures access to assets, even when a key team member leaves the project or becomes indisposed.
6060

6161
4. A system for distributing project secrets must have the following properties:
62-
6362
- Secrets are stored encrypted in a central (remote) location.
6463
- It must be possible to grant access to the secrets to a select group of team members.
6564
- It must be possible to revoke future access to the secrets.[^future-access]

spec-0007/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ The [deprecation strategy](https://github.com/scientific-python/specs/pull/180#i
9999

100100
- If neither `rng` nor `random_state`/`seed`/`...` is specified and `np.random.seed` has been used to set the seed, emit a `FutureWarning` about the upcoming change in behavior.
101101
- If `random_state`/`seed`/`...` is passed by keyword or by position, treat it as before, but:
102-
103102
- Emit a `DeprecationWarning` if passed by keyword, warning about the deprecation of keyword `random_state` in favor of `rng`.
104103
- Emit a `FutureWarning` if passed by position, warning about the change in behavior of the positional argument.
105104

0 commit comments

Comments
 (0)