Skip to content

Commit a26a51f

Browse files
authored
Switch to PyLint/Ruff from Prospector (#761)
Fixes #739
1 parent a25771a commit a26a51f

File tree

19 files changed

+152
-69
lines changed

19 files changed

+152
-69
lines changed

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- version: '3.11'
2828
tox-env: py311,py311-mypy,py311-lint,safety
2929
- version: '3.12'
30-
tox-env: py312,py312-mypy,format,safety
30+
tox-env: py312,py312-mypy,py312-lint,format,safety
3131
- os: windows-latest
3232
version: '3.12'
3333
tox-env: py312,safety

.prospector.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
* Removed `basilisp.__version__` in favor of using `importlib.metadata` for version info (#617)
3939
* Removed a shim to Python's `ast` module to support compatibility with Python 3.6 and 3.7 (#749)
4040

41+
### Other
42+
* Switch to PyLint and Ruff for linting from Prospector (#739)
43+
4144
## [v0.1.0a2]
4245
### Added
4346
* Added support for fixtures in `basilisp.test` (#654)

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ All three steps can be performed using a provided ``make`` target:
7777
7878
Testing is performed using `PyTest <https://github.com/pytest-dev/pytest/>`_.
7979
Type checking is performed by `MyPy <http://mypy-lang.org/>`_.
80-
Linting is performed using `Prospector <https://prospector.landscape.io/en/master/>`_.
80+
Linting is performed using `PyLint <https://github.com/pylint-dev/pylint>`_ and `Ruff <https://github.com/astral-sh/ruff>`_.
8181
Formatting is performed using `Black <https://github.com/psf/black>`_.
8282

8383
New *code* contributions should include test coverage covering all new branches unless otherwise directed by the project maintainers.

pyproject.toml

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,82 @@ skip = [
138138
"pip-wheel-metadata",
139139
]
140140

141+
[tool.pylint.main]
142+
ignore = [
143+
".cache",
144+
".env",
145+
".hg",
146+
".git",
147+
".mypy_cache",
148+
".pytest_cache",
149+
".tox",
150+
".venv",
151+
"build",
152+
"dist",
153+
"docs",
154+
"htmlcov",
155+
"junit",
156+
"pip-wheel-metadata",
157+
"lispcore.py",
158+
]
159+
ignore-patterns = ["^\\.#"]
160+
load-plugins = [
161+
"pylint.extensions.code_style",
162+
"pylint.extensions.docstyle",
163+
"pylint.extensions.private_import",
164+
"pylint.extensions.redefined_loop_name",
165+
"pylint.extensions.set_membership"
166+
]
167+
168+
[tool.pylint.basic]
169+
docstring-min-length = 5
170+
no-docstring-rgx = "^_"
171+
172+
[tool.pylint.logging]
173+
logging-format-style = "new"
174+
175+
[tool.pylint."messages control"]
176+
disable = [
177+
"bad-inline-option",
178+
"consider-using-assignment-expr",
179+
"deprecated-pragma",
180+
"docstring-first-line-empty",
181+
"duplicate-code",
182+
"file-ignored",
183+
"fixme",
184+
"global-statement",
185+
"implicit-str-concat",
186+
"import-outside-toplevel",
187+
"invalid-name",
188+
"len-as-condition",
189+
"line-too-long",
190+
"locally-disabled",
191+
"logging-format-interpolation",
192+
"logging-fstring-interpolation",
193+
"logging-too-many-args",
194+
"missing-class-docstring",
195+
"missing-function-docstring",
196+
"missing-module-docstring",
197+
"no-else-continue",
198+
"no-else-raise",
199+
"no-else-return",
200+
"protected-access",
201+
"raw-checker-failed",
202+
"redefined-outer-name",
203+
"redundant-keyword-arg",
204+
"suppressed-message",
205+
"too-few-public-methods",
206+
"too-many-ancestors",
207+
"too-many-public-methods",
208+
"too-many-instance-attributes",
209+
"trailing-whitespace",
210+
"unnecessary-lambda-assignment",
211+
"unspecified-encoding",
212+
"useless-import-alias",
213+
"useless-suppression",
214+
"use-symbolic-message-instead"
215+
]
216+
141217
[tool.mypy]
142218
check_untyped_defs = true
143219
mypy_path = "src/"
@@ -156,4 +232,26 @@ module = [
156232
ignore_missing_imports = true
157233

158234
[tool.pytest.ini_options]
159-
junit_family = "legacy"
235+
junit_family = "legacy"
236+
237+
[tool.ruff]
238+
exclude = [
239+
".cache",
240+
".env",
241+
".hg",
242+
".git",
243+
".mypy_cache",
244+
".pytest_cache",
245+
".tox",
246+
".venv",
247+
"build",
248+
"dist",
249+
"docs",
250+
"htmlcov",
251+
"junit",
252+
"pip-wheel-metadata",
253+
"lispcore.py",
254+
]
255+
256+
[tool.ruff.lint]
257+
ignore = ["E731", "E741"]

src/basilisp/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def repl(
368368
)
369369
repl_module.mark_exception(e)
370370
continue
371-
except Exception as e:
371+
except Exception as e: # pylint: disable=broad-exception-caught
372372
traceback.print_exception(Exception, e, e.__traceback__)
373373
repl_module.mark_exception(e)
374374
continue

src/basilisp/contrib/sphinx/autodoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import types
66
from typing import Any, Dict, List, Optional, Tuple, cast
77

8-
from sphinx.ext.autodoc import (
8+
from sphinx.ext.autodoc import ( # pylint: disable=no-name-in-module
99
ClassDocumenter,
1010
Documenter,
1111
ObjectMember,

src/basilisp/contrib/sphinx/domain.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def run(self) -> List[Node]:
130130
return ret
131131

132132

133-
class BasilispObject(PyObject):
133+
class BasilispObject(PyObject): # pylint: disable=abstract-method
134134
def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]:
135135
"""Subclasses should implement this themselves."""
136136
return NotImplemented
@@ -196,7 +196,7 @@ def get_index_text(self, modname: str, name: Tuple[str, str]) -> str:
196196
return f"{sig} ({prefix} in {modname})"
197197

198198

199-
class BasilispFunctionLike(BasilispObject):
199+
class BasilispFunctionLike(BasilispObject): # pylint: disable=abstract-method
200200
option_spec: OptionSpec = BasilispObject.option_spec.copy()
201201

202202
def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]:
@@ -314,14 +314,16 @@ def generate( # pylint: disable=too-many-locals
314314

315315
for ignore in ignores:
316316
if nsname.startswith(ignore):
317-
nsname = nsname[len(ignore) :]
317+
nsname = nsname[ # pylint: disable=redefined-loop-name
318+
len(ignore) :
319+
]
318320
stripped = ignore
319321
break
320322
else:
321323
stripped = ""
322324

323325
if not nsname:
324-
nsname, stripped = stripped, ""
326+
nsname, stripped = stripped, "" # pylint: disable=redefined-loop-name
325327

326328
entries = content[nsname[0].lower()]
327329

@@ -562,3 +564,14 @@ def resolve_xref( # pylint: disable=too-many-arguments
562564
return make_refnode(
563565
builder, fromdocname, docname, node_id, contnode, title=title
564566
)
567+
568+
def resolve_any_xref( # pylint: disable=too-many-arguments
569+
self,
570+
env: BuildEnvironment,
571+
fromdocname: str,
572+
builder: Builder,
573+
target: str,
574+
node: pending_xref,
575+
contnode: Element,
576+
) -> List[Tuple[str, Element]]:
577+
raise NotImplementedError

src/basilisp/importer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def _is_namespace_package(path: str) -> bool:
123123
return no_inits and has_basilisp_files
124124

125125

126-
class BasilispImporter(MetaPathFinder, SourceLoader):
126+
class BasilispImporter(MetaPathFinder, SourceLoader): # pylint: disable=abstract-method
127127
"""Python import hook to allow directly loading Basilisp code within
128128
Python."""
129129

src/basilisp/lang/compiler/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def compile_and_exec_form(
182182
bytecode = compile(ast_module, ctx.filename, "exec")
183183
if collect_bytecode:
184184
collect_bytecode(bytecode)
185-
exec(bytecode, ns.module.__dict__)
185+
exec(bytecode, ns.module.__dict__) # pylint: disable=exec-used
186186
try:
187187
return getattr(ns.module, final_wrapped_name)()
188188
finally:
@@ -215,7 +215,7 @@ def _incremental_compile_module(
215215
bytecode = compile(module, source_filename, "exec")
216216
if collect_bytecode:
217217
collect_bytecode(bytecode)
218-
exec(bytecode, ns.module.__dict__)
218+
exec(bytecode, ns.module.__dict__) # pylint: disable=exec-used
219219

220220

221221
def _bootstrap_module(
@@ -277,4 +277,4 @@ def compile_bytecode(
277277
and then proceeds to compile a collection of bytecodes into the module."""
278278
_bootstrap_module(gctx, optimizer, ns)
279279
for bytecode in code:
280-
exec(bytecode, ns.module.__dict__)
280+
exec(bytecode, ns.module.__dict__) # pylint: disable=exec-used

0 commit comments

Comments
 (0)