Skip to content

Commit

Permalink
Updates and fixes (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apakottur authored Aug 6, 2024
1 parent ed1c89f commit 19e04e1
Show file tree
Hide file tree
Showing 15 changed files with 401 additions and 161 deletions.
4 changes: 0 additions & 4 deletions .darglint

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install pre-commit requirements
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Install Poetry
run: pip install poetry
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
.tmp
__pycache__
.venv
.cspellcache
54 changes: 27 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
default_language_version:
python: python3.11
python: python3.12
repos:
###########
# GENERAL #
###########
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ["--maxkb=2000"]
Expand Down Expand Up @@ -47,12 +47,24 @@ repos:
hooks:
- id: taplo-docker
args: [format, --config, ./linters/taplo.toml]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
args: ['--config-file', './linters/yamllint.yaml']
- repo: https://github.com/biomejs/pre-commit
rev: v0.1.0
rev: v0.4.0
hooks:
- id: biome-check
args: [--config-path, ./linters]
additional_dependencies: ["@biomejs/[email protected]"]
additional_dependencies: ["@biomejs/[email protected]"]
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.13.1
hooks:
- id: cspell
exclude: \.(csv|json|txt|lock)$
args: ["lint", "-c", "./linters/cspell.json", "--no-progress",
"--cache", "--cache-location", "./linters/.cspellcache"]
##########
# PYTHON #
##########
Expand All @@ -62,43 +74,31 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
types: [file]
types_or: [python, pyi]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.5.6
hooks:
- id: ruff
args: [ --config, ./linters/ruff.toml ]
args: [--config, ./linters/ruff.toml]
- id: ruff-format
args: [ --config, ./linters/ruff.toml ]

args: [--config, ./linters/ruff.toml]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==24.2.6
- flake8-comprehensions==3.14.0
- flake8-picky-parentheses==0.5.4
- flake8-pyi==24.1.0
- pep8-naming==0.13.3
- pydoclint==0.3.10
- flake8-bugbear==24.4.26
- flake8-comprehensions==3.15.0
- flake8-picky-parentheses==0.5.5
- flake8-pyi==24.6.0
- pep8-naming==0.14.1
- pydoclint==0.5.6
args: [--config, ./linters/.flake8]
types: [file]
types_or: [python, pyi]
- repo: https://github.com/terrencepreilly/darglint
rev: v1.8.1
hooks:
- id: darglint
- repo: https://github.com/jendrikseipp/vulture
rev: v2.10
rev: v2.11
hooks:
- id: vulture
args: ["src", "tests"]
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ inputs:
pr-body:
description: "The body of the pull request"
required: false
default: "Automated changes by [update-python-poetry-packages](https://github.com/Apakottur/action-poetry-package-update) GitHub action"
default:
"Automated changes by [update-python-poetry-packages](https://github.com/Apakottur/action-poetry-package-update)
GitHub action"
runs:
using: "composite"
steps:
Expand Down
12 changes: 10 additions & 2 deletions linters/.flake8
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ ignore =
################################################
# Ignored - we rely on ruff to format our code #
################################################
# Whitespace after '{'
E201
# Whitespace before '}'
E202
# Whitespace before ':'
E203
# At least two spaces before inline comment
Expand All @@ -36,6 +40,8 @@ ignore =
E501
# multiple statements on one line
E704
# Variable X in class scope should not be mixedCase
N815
# Only operators and comments are allowed after a closing bracket on a new line
PAR104
# Line break occurred before a binary operator
Expand All @@ -51,6 +57,10 @@ ignore =
# Unnecessary generator
C401
# Unnecessary list comprehension
C403
# Unnecessary set comprehension
C416
# Unnecessary list comprehension
C419
# Module level import not at top of file
E402
Expand Down Expand Up @@ -82,8 +92,6 @@ ignore =
DOC203
# Class X should not have a docstring; please combine it with the docstring of the class
DOC301
# Method X has "yield" statements, but the docstring does not have a "Yields" section
DOC402
# Method X yield type(s) in docstring not consistent with the return annotation.
DOC404

Expand Down
10 changes: 10 additions & 0 deletions linters/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dictionaries": ["custom-words"],
"dictionaryDefinitions": [
{
"name": "custom-words",
"path": "./cspell/words.txt",
"addWords": true
}
]
}
29 changes: 29 additions & 0 deletions linters/cspell/words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
mypy
pyproject
pytest
typer
tomlkit
shpyx
sqlalchemy
classmethod
isort
pydoclint
pydocstyle
elif
contextlib
taplo
shfmt
noqa
apakottur
numpy
venv
pycache
yossi
rozantsev
asyncpg
pythonpath
shellcheck
pydantic
ignorelist
docstrings
biomejs
45 changes: 21 additions & 24 deletions linters/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@
line-length = 120

# Python version.
target-version = "py311"
target-version = "py312"

# Enable autofixing.
fix = true

# Output format, can be used to print more detailed errors.
output-format = "concise"

[format]
# Enable everything by default.
preview = true
# Preview mode is unstable and should not be used.
preview = false

quote-style = "double"
indent-style = "space"


[lint]
# Enable everything by default.
preview = true
# Preview mode is unstable and should not be used.
preview = false

# Enable everything else.
select = ["ALL"]
fixable = ["ALL"]
unfixable = []
Expand All @@ -31,9 +37,8 @@ ignore = [
# Ignored - Conflicts with Ruff formatter #
###########################################
"COM812", # Trailing comma missing
"E203", # Whitespace before ':'
"E501", # Line too long
"ISC001", # Implicitly concatenated string literals on one line
"ISC001", # Implicitly concatenated strings on a single line
##############
# Pydocstyle #
##############
Expand All @@ -53,48 +58,40 @@ ignore = [
###################################
# Other checks that we don't want #
###################################
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"BLE001", # Do not catch blind exception: `Exception`
"C901", # Method is too complex
"CPY001", # Missing copyright notice at top of file
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"ERA001", # Found commented-out code
"FIX002", # Line contains TODO
"FURB101", # Replace `read` and `open` by `pathlib` methods.
"ISC003", # Explicitly concatenated string should be implicitly concatenate
"N818", # Exception name should be named with an Error suffix
"PD011", # Use `.to_numpy()` instead of `.values`
"PLR0904", # Too many public methods
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments to function call
"PLR0914", # Too many local variables
"PLR0915", # Too many statements
"PLR0917", # Too many positional arguments
"PLR1722", # Use `sys.exit()` instead of `exit`
"PLR2004", # Magic value used in comparison, consider replacing with a constant variable
"PLR5501", # Consider using `elif` instead of `else` then `if` to remove one indentation level
"PLR6301", # Method X could be a function or static method
"PLW1514", # `open` in text mode without explicit `encoding` argument
"PTH123", # `open()` should be replaced by `Path.open()`
"RET505", # Unnecessary `else` after `return` statement
"RET506", # Unnecessary `else` after `raise` statement
"SIM102", # Use a single `if` statement instead of nested `if` statements
"SIM103", # Return the condition directly
"SIM105", # Use `contextlib.suppress()` instead of try-except-pass
"TCH001", # Move application import into a type-checking block
"TCH002", # Move third-party import into a type-checking block
"TCH003", # Move standard library import into a type-checking block
"TD002", # Missing author in TODO
"TD003", # Missing issue link on the line following this TODO
"TD005", # Missing issue description after `TODO`
"TRY003", # Avoid specifying long messages outside the exception class
]


[lint.isort]
# Import sorting configuration.
isort = {known-first-party = ["shared"], combine-as-imports = true}
split-on-trailing-comma = false
combine-as-imports = true

[lint.pydocstyle]
# Use Google-style docstrings.
Expand All @@ -110,10 +107,10 @@ builtins-ignorelist = ["id"]

# Per file ignores.
[lint.per-file-ignores]
"src/*" = [
"T201", # `print` found
"tests/*" = [
"S101", # Use of `assert` detected
]

"tests/*" = [
"S101", # Use of assert detected
"src/*" = [
"T201", # `print` found
]
19 changes: 19 additions & 0 deletions linters/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends: default

rules:
line-length:
max: 120

document-start:
present: false


comments:
require-starting-space: true
ignore-shebangs: true
min-spaces-from-content: 1


truthy:
allowed-values: ['true', 'false', 'on', 'off']
check-keys: true
Loading

0 comments on commit 19e04e1

Please sign in to comment.