Skip to content
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

Revisit linting for SIMPLE scripts/functions #543

Open
dr-rodriguez opened this issue Jul 25, 2024 · 1 comment
Open

Revisit linting for SIMPLE scripts/functions #543

dr-rodriguez opened this issue Jul 25, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request tests

Comments

@dr-rodriguez
Copy link
Collaborator

We should add a linter step as part of our testing infrastructure for SIMPLE. I recommend using ruff with a toml file for handling settings.
This is what I've used before as a run_lint.sh script:

#!/usr/bin/env bash

# Requires ruff in the current environment

# Summary
echo "Summary"
ruff check . --config=pyproject.toml --statistics

# To fix issues (eg, import sorting):
# ruff check . --config=pyproject.toml --statistics --fix

# Main invocation
echo "\nDetails"
ruff check . --config=pyproject.toml --exit-zero

where pyproject.toml contains something like:

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
# See https://docs.astral.sh/ruff/rules/
select = ["E4", "E7", "E9", "F", "I", "PL", "C901", "RUF010"]
#select = ["ALL"]
ignore = ["PLR",  # pylint refactor
          "E701", # multiple statements on one line (revisit?)
          ]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

[tool.ruff]
line-length = 120
src = ["src"]
exclude = ["test"]

[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds this number.
max-complexity = 10
@dr-rodriguez dr-rodriguez self-assigned this Jul 25, 2024
@dr-rodriguez dr-rodriguez added enhancement New feature or request tests labels Jul 25, 2024
@kelle
Copy link
Collaborator

kelle commented Jul 25, 2024

Would this just flag problems or also fix them?

I am more inclined to set this up in astrodb_utils since I think we should hold that code to a higher standard while I think of SIMPLE as more of a testbed.

I would also like to include instructions in our dev docs for adding this to ones VS Code setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests
Projects
None yet
Development

No branches or pull requests

2 participants