Skip to content

Commit 10f5abb

Browse files
committed
refactor: rename
1 parent 4fb2bba commit 10f5abb

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

src/sp_repo_review/checks/noxfile.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# NOX: Noxfile checks
2-
## NOXxxx: noxfile checks
1+
# NOX: Nox checks
2+
## NOX1xx: Contents of noxfile
3+
## NOX2xx: Script mode for noxfile
34

45
from __future__ import annotations
56

@@ -18,23 +19,23 @@
1819

1920

2021
@dataclasses.dataclass(frozen=True, kw_only=True, slots=True, eq=False)
21-
class NoxfileInfo:
22+
class Noxfile:
2223
module: ast.Module
2324
shebang: str
2425
script: dict[str, Any]
2526

2627
__hash__ = None # type: ignore[assignment]
2728

2829
@classmethod
29-
def from_str(cls, content: str) -> NoxfileInfo:
30+
def from_str(cls, content: str) -> Noxfile:
3031
module = ast.parse(content, filename="noxfile.py")
3132
shebang_match = re.match(r"^#!.*\n", content)
3233
shebang = shebang_match.group(0).strip() if shebang_match else ""
3334
script = _load_script_block(content)
3435
return cls(module=module, shebang=shebang, script=script)
3536

3637
def __eq__(self, other: object) -> bool:
37-
if not isinstance(other, NoxfileInfo):
38+
if not isinstance(other, Noxfile):
3839
return NotImplemented
3940

4041
ast_equal = ast.dump(self.module, include_attributes=True) == ast.dump(
@@ -63,7 +64,7 @@ def _load_script_block(content: str, /) -> dict[str, Any]:
6364
return tomllib.loads(content)
6465

6566

66-
def noxfile(root: Traversable) -> NoxfileInfo | None:
67+
def noxfile(root: Traversable) -> Noxfile | None:
6768
"""
6869
Returns the shebang line (or empty string if missing), the noxfile script block, and the AST of the noxfile.py.
6970
Returns None if noxfile.py is not present.
@@ -74,20 +75,20 @@ def noxfile(root: Traversable) -> NoxfileInfo | None:
7475
return None
7576

7677
with noxfile_path.open("r", encoding="utf-8") as f:
77-
return NoxfileInfo.from_str(f.read())
78+
return Noxfile.from_str(f.read())
7879

7980

80-
class Noxfile:
81+
class Nox:
8182
family = "noxfile"
8283
requires = {"PY007"}
8384
url = mk_url("tasks")
8485

8586

86-
class NOX101(Noxfile):
87+
class NOX101(Nox):
8788
"Sets minimum nox version"
8889

8990
@staticmethod
90-
def check(noxfile: NoxfileInfo | None) -> bool | None:
91+
def check(noxfile: Noxfile | None) -> bool | None:
9192
"""Set a minimum nox version:
9293
9394
```python
@@ -110,11 +111,11 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
110111
return False
111112

112113

113-
class NOX102(Noxfile):
114+
class NOX102(Nox):
114115
"Sets venv backend"
115116

116117
@staticmethod
117-
def check(noxfile: NoxfileInfo | None) -> bool | None:
118+
def check(noxfile: Noxfile | None) -> bool | None:
118119
"""
119120
The default venv backend should be set, ideally to `uv|virtualenv`:
120121
@@ -140,11 +141,11 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
140141
return False
141142

142143

143-
class NOX103(Noxfile):
144+
class NOX103(Nox):
144145
"Set default per session instead of session list"
145146

146147
@staticmethod
147-
def check(noxfile: NoxfileInfo | None) -> bool | None:
148+
def check(noxfile: Noxfile | None) -> bool | None:
148149
"""
149150
You should use `default=` in each session instead of setting a global list.
150151
"""
@@ -166,11 +167,11 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
166167
return True
167168

168169

169-
class NOX201(Noxfile):
170+
class NOX201(Nox):
170171
"Set a script block with dependencies in your noxfile"
171172

172173
@staticmethod
173-
def check(noxfile: NoxfileInfo | None) -> bool | None:
174+
def check(noxfile: Noxfile | None) -> bool | None:
174175
"""
175176
You should have a script block with nox in it, for example:
176177
@@ -188,11 +189,11 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
188189
return False
189190

190191

191-
class NOX202(Noxfile):
192+
class NOX202(Nox):
192193
"Has a shebang line"
193194

194195
@staticmethod
195-
def check(noxfile: NoxfileInfo | None) -> bool | None:
196+
def check(noxfile: Noxfile | None) -> bool | None:
196197
"""
197198
You should have a shebang line at the top of your noxfile.py, for example:
198199
@@ -205,11 +206,11 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
205206
return bool(noxfile.shebang)
206207

207208

208-
class NOX203(Noxfile):
209+
class NOX203(Nox):
209210
"Provide a main block to run nox"
210211

211212
@staticmethod
212-
def check(noxfile: NoxfileInfo | None) -> bool | None:
213+
def check(noxfile: Noxfile | None) -> bool | None:
213214
"""
214215
You should have a main block at the bottom of your noxfile.py, for example:
215216
@@ -235,8 +236,8 @@ def check(noxfile: NoxfileInfo | None) -> bool | None:
235236

236237

237238
def repo_review_checks(
238-
list_all: bool = True, noxfile: NoxfileInfo | None = None
239-
) -> dict[str, Noxfile]:
239+
list_all: bool = True, noxfile: Noxfile | None = None
240+
) -> dict[str, Nox]:
240241
if not list_all and noxfile is None:
241242
return {}
242-
return {p.__name__: p() for p in Noxfile.__subclasses__()}
243+
return {p.__name__: p() for p in Nox.__subclasses__()}

0 commit comments

Comments
 (0)