Skip to content

Commit

Permalink
Update ruff rules and add cspell
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSuperiorStanislav committed Aug 9, 2024
1 parent 2200af4 commit 4124224
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/project-related-words.txt
!.vscode/cspell.json
*.code-workspace

# Local History for Visual Studio Code
Expand Down
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
args: ["--lock"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.5.7
hooks:
- id: ruff
args: [ --fix ]
Expand All @@ -42,6 +42,11 @@ repos:
--blank
]

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.2
hooks:
- id: cspell

- repo: local
hooks:
- id: check_list
Expand Down
19 changes: 19 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"ignorePaths": [
".gitignore"
],
"dictionaryDefinitions": [
{
"name": "project-related-words",
"path": "./project-related-words.txt",
"addWords": true
}
],
"dictionaries": [
"python",
"python-common",
"docker",
"project-related-words"
],
"useGitignore": true
}
27 changes: 27 additions & 0 deletions .vscode/project-related-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
autoupdate
buildpack
buildpacks
charliermarsh
compilemessages
createsuperuser
dbshell
FURB
htmlcov
Khlud
localstack
makemessages
makemigration
makemigrations
opensearch
paketobuildpacks
paketobuildpacks
Pylance
Renderable
resetdb
runserver
saritasa
snok
Stanislav
startapp
TASKNUMBER
RUF
52 changes: 37 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,42 +114,58 @@ extend-select = [
"TD",
# https://docs.astral.sh/ruff/rules/#eradicate-era
"ERA",
# https://docs.astral.sh/ruff/rules/#tryceratops-try
"TRY",
# https://docs.astral.sh/ruff/rules/#flynt-fly
"FLY",
# https://docs.astral.sh/ruff/rules/#perflint-perf
"PERF",
# https://docs.astral.sh/ruff/rules/#refurb-furb
"FURB",
# https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"PIE",
# https://docs.astral.sh/ruff/rules/#flake8-async-async
"ASYNC",
# https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
"RUF"
"RUF",
]
ignore = [
# https://docs.astral.sh/ruff/rules/ANN101
# https://docs.astral.sh/ruff/rules/missing-type-self
"ANN101",
# https://docs.astral.sh/ruff/rules/ANN102
# https://docs.astral.sh/ruff/rules/missing-type-cls
"ANN102",
# https://docs.astral.sh/ruff/rules/ANN401
# https://docs.astral.sh/ruff/rules/any-type
"ANN401",
# https://docs.astral.sh/ruff/rules/ANN003
# https://docs.astral.sh/ruff/rules/missing-type-kwargs
"ANN003",
# https://docs.astral.sh/ruff/rules/D100
# https://docs.astral.sh/ruff/rules/undocumented-public-module
"D100",
# https://docs.astral.sh/ruff/rules/D104
# https://docs.astral.sh/ruff/rules/undocumented-public-package
"D104",
# https://docs.astral.sh/ruff/rules/D106
# https://docs.astral.sh/ruff/rules/undocumented-public-nested-class
"D106",
# https://docs.astral.sh/ruff/rules/D107
# https://docs.astral.sh/ruff/rules/undocumented-public-init
"D107",
# https://docs.astral.sh/ruff/rules/raise-vanilla-args
"TRY003",
# https://docs.astral.sh/ruff/rules/try-consider-else
"TRY300",
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
# https://docs.astral.sh/ruff/rules/F401
# https://docs.astral.sh/ruff/rules/unused-import
"F401",
]
"**/tests/*" = [
# https://docs.astral.sh/ruff/rules/S101
# https://docs.astral.sh/ruff/rules/assert
"S101",
# https://docs.astral.sh/ruff/rules/S106
# https://docs.astral.sh/ruff/rules/hardcoded-password-func-arg
"S106",
# https://docs.astral.sh/ruff/rules/S311
# https://docs.astral.sh/ruff/rules/suspicious-non-cryptographic-random-usage
"S311",
]
"**/test_*" = [
# https://docs.astral.sh/ruff/rules/ANN201
# https://docs.astral.sh/ruff/rules/missing-return-type-undocumented-public-function
"ANN201",
]
[tool.ruff.lint.isort]
Expand All @@ -175,7 +191,6 @@ indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"


[tool.mypy]
# https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
ignore_missing_imports = true
Expand All @@ -184,3 +199,10 @@ warn_no_return = false
check_untyped_defs = true
disallow_any_generics = true
exclude = "venv|/.venv"

# https://docformatter.readthedocs.io/en/latest/configuration.html#
[tool.docformatter]
wrap-descriptions=0
in-place=true
blank=true
black=true
3 changes: 1 addition & 2 deletions saritasa_invocations/alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def wait_for_database(context: invoke.Context) -> None:
)
wait_for_database._called = True # type: ignore
return
except invoke.UnexpectedExit:
except invoke.UnexpectedExit: # noqa: PERF203
time.sleep(1)
continue

Expand All @@ -51,7 +51,6 @@ def wait_for_database(context: invoke.Context) -> None:
command=f"{config.alembic.command} current",
)
wait_for_database._called = True # type: ignore
return
except invoke.UnexpectedExit as error:
printing.print_error(
"Failed to connect to db, "
Expand Down
4 changes: 2 additions & 2 deletions saritasa_invocations/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def up_containers(
up_cmd = f"{compose_cmd} up {detach_str} {containers_str}"
try:
context.run(up_cmd)
except invoke.UnexpectedExit as exception:
except invoke.UnexpectedExit:
if not stop_others:
raise exception
raise
stop_all_containers(context)
context.run(up_cmd)

Expand Down
4 changes: 2 additions & 2 deletions saritasa_invocations/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def update_to_latest(
printing.print_success("Update dependencies to latest versions")
try:
context.run(f"poetry up --latest {params} {_parse_groups(groups)}")
except invoke.UnexpectedExit as error:
except invoke.UnexpectedExit:
if not fallback:
raise error
raise
printing.print_warn(
"Can't update to latest, try to update with respect to version"
" constraints.",
Expand Down
2 changes: 1 addition & 1 deletion saritasa_invocations/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _rewrite_file(
) -> None:
"""Copy file to destination."""
if force_update or not pathlib.Path(to_path).is_file():
context.run(" ".join(("cp", from_path, to_path)))
context.run(f"cp {from_path} {to_path}")


@invoke.task
Expand Down

0 comments on commit 4124224

Please sign in to comment.