Skip to content

Commit 756f9ba

Browse files
committed
Add ruff lint rules for builtins, pathlib, and print detection
- Add A (builtins shadowing), PTH (pathlib), T20 (print) rules - Fix: use Path.open() instead of open() in main.py - Fix: rename vars to tpl_vars to avoid shadowing builtin - Ignore T201 (print) in test files
1 parent f7da23e commit 756f9ba

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

pyproject.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,18 @@ exclude = ["src/mxmake/_version.py"]
9595

9696
[tool.ruff.lint]
9797
select = [
98+
"A", # flake8-builtins (shadowing builtins)
99+
"B", # flake8-bugbear
100+
"C4", # flake8-comprehensions
98101
"E", # pycodestyle errors
99102
"F", # pyflakes
100-
"W", # pycodestyle warnings
101-
"B", # flake8-bugbear
102103
"I", # isort
103-
"UP", # pyupgrade
104-
"C4", # flake8-comprehensions
105-
"SIM", # flake8-simplify
104+
"PTH", # flake8-use-pathlib
106105
"RUF", # ruff-specific
106+
"SIM", # flake8-simplify
107+
"T20", # flake8-print
108+
"UP", # pyupgrade
109+
"W", # pycodestyle warnings
107110
]
108111

109112
[tool.ruff.lint.isort]
@@ -118,4 +121,4 @@ order-by-type = false
118121
max-line-length = 120 # E501 triggers above this, allows flexibility
119122

120123
[tool.ruff.lint.per-file-ignores]
121-
"src/mxmake/tests/*" = ["E101", "RUF012"]
124+
"src/mxmake/tests/*" = ["E101", "RUF012", "T201"]

src/mxmake/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def init_command(args: argparse.Namespace):
308308
preseeds = None
309309
if args.preseeds:
310310
prompt = False
311-
with open(args.preseeds) as fd:
311+
with Path(args.preseeds).open() as fd:
312312
preseeds = yaml.load(fd.read(), yaml.SafeLoader)
313313

314314
# Handle project-path-python from CLI or auto-detection

src/mxmake/templates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,15 @@ def target_folder(self) -> Path:
536536
@property
537537
def template_variables(self):
538538
site = {}
539-
vars = {"site": site}
539+
tpl_vars = {"site": site}
540540
site.setdefault("site_id", "Plone")
541541
site.setdefault("title", "Plone Site")
542542
site.setdefault("setup_content", False)
543543
site.setdefault("default_language", "en")
544544
site.setdefault("portal_timezone", "UTC")
545545
site.update(**self.settings)
546546
if "distribution" in site:
547-
vars["distribution"] = site.pop("distribution")
547+
tpl_vars["distribution"] = site.pop("distribution")
548548

549549
# handle extension ids
550550
if site.get("extension_ids") is not None:
@@ -553,7 +553,7 @@ def template_variables(self):
553553
]
554554
else:
555555
site["extension_ids"] = []
556-
return vars
556+
return tpl_vars
557557

558558

559559
##############################################################################

0 commit comments

Comments
 (0)