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

Fixing ruff and black linting #66

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/flake8.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check black formatting
name: Check Python formatting using Black and Ruff

on: [push]

Expand All @@ -8,3 +8,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- uses: chartboost/ruff-action@v1
17 changes: 11 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
ci:
autoupdate_schedule: monthly


repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
language_version: python3.11
language_version: python3.10

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
hooks:
- id: isort
name: isort (python)
- id: ruff
args: ["--fix", "--format=github"]
language_version: python3.10
30 changes: 15 additions & 15 deletions acis_thermal_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ def make_week_predict(self, tstart, tstop, tlm, T_init, model_spec, outdir):
# write_temps writes the temperatures to temperatures.dat
self.write_temps(outdir, model.times, temps)

return dict(
states=states,
times=model.times,
temps=temps,
plots=plots,
viols=viols,
)
return {
"states": states,
"times": model.times,
"temps": temps,
"plots": plots,
"viols": viols,
}

def _calc_model_supp(self, model, state_times, states, ephem, state0):
pass
Expand Down Expand Up @@ -1426,14 +1426,14 @@ def _setup_proc_and_logger(self, args):
config_logging(args.outdir, args.verbose)

# Store info relevant to processing for use in outputs
proc = dict(
run_user=getpass.getuser(),
run_time=time.ctime(),
errors=[],
msid=self.msid.upper(),
name=self.name.upper(),
hist_limit=self.hist_limit,
)
proc = {
"run_user": getpass.getuser(),
"run_time": time.ctime(),
"errors": [],
"msid": self.msid.upper(),
"name": self.name.upper(),
"hist_limit": self.hist_limit,
}

mylog.info(
"# %s_check run at %s by %s"
Expand Down
150 changes: 108 additions & 42 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,119 @@ exclude = '''
)/
'''

[tool.isort]
profile = "black"

[tool.ruff]
line-length = 88
select = ["ALL"]
target-version = "py310"
# fix = true
select = [
# isort
"I",
# pyflakes
"F",
# pycodestyle
"E", "W",
# flake8-2020
"YTT",
# flake8-bugbear
"B",
# flake8-quotes
"Q",
# flake8-debugger
"T10",
# flake8-gettext
"INT",
# pylint
"PLC", "PLE", "PLR", "PLW",
# misc lints
"PIE",
# flake8-pyi
"PYI",
# tidy imports
"TID",
# implicit string concatenation
"ISC",
# type-checking imports
"TCH",
# comprehensions
"C4",
# pygrep-hooks
"PGH"
]

ignore = [
"ANN",
"S101",
"D1",
"D400",
"D401",
"D404",
"D415",
"D203",
"SIM105",
"SIM108",
"PTH123",
"DTZ",
"D212",
"EM",
"ERA001",
"C",
"B905",
"BLE001",
"T",
"RET",
"D205",
"N802",
"N803",
"N806",
"S324",
"FBT002",
"FBT003",
"ARG002",
"B904",
"PLR2004",
"PLR0915",
"ICN001",
"TRY003",
"PLR0912",
"PLR0913",
"TRY200",
# space before : (needed for how black formats slicing)
# "E203", # not yet implemented
# module level import not at top of file
"E402",
# do not assign a lambda expression, use a def
"E731",
# line break before binary operator
# "W503", # not yet implemented
# line break after binary operator
# "W504", # not yet implemented
# controversial
"B006",
# controversial?: Loop control variable not used within loop body
# "B007",
# controversial
"B008",
# setattr is used to side-step mypy
"B009",
# getattr is used to side-step mypy
"B010",
# tests use assert False
"B011",
# tests use comparisons but not their returned value
"B015",
# false positives
"B019",
# Loop control variable overrides iterable it iterates
"B020",
# Function definition does not bind loop variable
"B023",
# Functions defined inside a loop must not use variables redefined in the loop
# "B301", # not yet implemented
# Only works with python >=3.10
"B905",
# Too many arguments to function call
"PLR0913",
# Too many returns
"PLR0911",
# Too many branches
"PLR0912",
# Too many statements
"PLR0915",
# Redefined loop name
"PLW2901",
# Global statements are discouraged
"PLW0603",
# Docstrings should not be included in stubs
"PYI021",
# No builtin `eval()` allowed
"PGH001",
# compare-to-empty-string
"PLC1901",
# Use typing_extensions.TypeAlias for type aliases
# "PYI026", # not yet implemented
# Use "collections.abc.*" instead of "typing.*" (PEP 585 syntax)
# "PYI027", # not yet implemented
# while int | float can be shortened to float, the former is more explicit
# "PYI041", # not yet implemented
# Additional checks that don't pass yet
# Useless statement
"B018",
# Within an except clause, raise exceptions with ...
"B904",
# Magic number
"PLR2004",
# Consider `elif` instead of `else` then `if` to remove indentation level
"PLR5501",
]
extend-exclude = [
"doc",

exclude = [
"docs",
]


[tool.ruff.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]
15 changes: 15 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[pytest]
filterwarnings =
# most probably, all these are stupid self-deprecation
ignore:Jupyter is migrating its paths
ignore:Importing clear_output from IPython.core.display is deprecated
ignore:Importing display from IPython.core.display is deprecated
ignore:\n\n `numpy.distutils` is deprecated:DeprecationWarning

ignore:distutils Version classes are deprecated

ignore: the imp module is deprecated

# these are convenient to have around to configure logging from pytest
log_cli = False
log_cli_level = DEBUG