-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup for automated code quality #58
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from pathlib import Path | ||
|
||
import nox | ||
|
||
RUN_DEPS = ["geopandas", "pint", "dataretrieval"] | ||
|
||
FORMAT_DEPS = ["ruff >= 0.3.5"] | ||
TESTS_DEPS = ["pytest", "coverage"] | ||
|
||
ROOT_PATH = Path.cwd() | ||
SRC_PATH = ROOT_PATH / "harmonize_wq" | ||
TESTS_PATH = SRC_PATH / "tests" | ||
DOCS_PATH = ROOT_PATH / "docs" | ||
|
||
nox.options.reuse_venv = "yes" | ||
nox.options.sessions = ["format"] | ||
|
||
|
||
@nox.session | ||
def format(session): | ||
"""Apply coding style standards to code.""" | ||
session.install(*FORMAT_DEPS) | ||
session.run("ruff", "format", SRC_PATH) | ||
session.run("ruff", "check", "--fix", SRC_PATH) | ||
|
||
|
||
@nox.session | ||
def tests(session): | ||
"""Run tests and compute code coverage.""" | ||
session.install(*RUN_DEPS) | ||
session.install(*TESTS_DEPS) | ||
session.run("coverage", "run", "-m", "pytest", *session.posargs, TESTS_PATH) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,20 @@ doc = ["sphinx"] | |
"Homepage" = "https://github.com/USEPA/harmonize-wq" | ||
"Documentation" = "https://usepa.github.io/harmonize-wq/" | ||
"Bug Tracker" = "https://github.com/USEPA/harmonize-wq/issues" | ||
|
||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"E", | ||
"F", | ||
"W", | ||
"I" | ||
] | ||
Comment on lines
+41
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: You might want to take a look at the list of rules available. This configuration is equivalent to flake8 + isort, but we could want a different set of rules for Rules can also be ignored:
|
||
|
||
[tool.ruff.lint.isort] | ||
known-first-party = ["harmonize_wq"] | ||
|
||
[tool.ruff.format] | ||
quote-style = "single" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. discussion: The default format used by black (and ruff as well) is to use double quotes for strings. However, this option will avoid messing with the full code base |
||
docstring-code-format = true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Ideally, we want to keep those in sync with the deps listed in
pyproject.toml
.