Skip to content

Commit

Permalink
ci/cd: update workflows, ruff rules and pre-commit hooks (#418)
Browse files Browse the repository at this point in the history
* ci/cd: add `toml-sort` precommit

* ci/cd: add new pre-commits

General propose:
- `check-merge-conflict`
- `name-tests-test`
- `check-illegal-windows-names`

These are for the release scripts:
- `check-executables-have-shebangs`
- `check-shebang-scripts-are-executable`
- `check-added-large-files`
- `check-case-conflict`

* ci/cd: add new `ruff` rules

New rules:
- `ASYNC` # async calls that do not await anything or use blocking methods
- `FA102`  # future annotations
- `PTH`  # use pathlib instead of os
- `T20`  # flake8-print
- `TID`  # flake8-tidy-imports

Change rules
- Replace `TCH` with `TC` (new name for type checking imports) and add it as a safe fix
- Marked `ERA` (commented out code) as unfixable

Ignore:
- Ignore `E402` on `__init__.py` files and `tests` and `docs` folders

* fix: add `T20` exclude on `tests` and `docs` folder
  • Loading branch information
NTFSvolume authored Jan 3, 2025
1 parent 2f6bbdd commit 30a03db
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
uses: actions/checkout@v4

- name: ruff lint
uses: astral-sh/ruff-action@v1
uses: astral-sh/ruff-action@v3
with:
version: v0.8.0
version: "0.8.0"

- name: ruff format check
uses: astral-sh/ruff-action@v1
uses: astral-sh/ruff-action@v3
with:
args: "format --check"
version: v0.8.0
version: "0.8.0"
20 changes: 17 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: name-tests-test
args: [ --pytest-test-first ]
- id: trailing-whitespace
args: [ --markdown-linebreak-ext=md ]

- repo: https://github.com/pappasam/toml-sort
rev: v0.24.2
hooks:
- id: toml-sort-fix
files: ^(.*\.toml)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
Expand Down
80 changes: 51 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tool.poetry]
name = "cyberdrop-dl-patched"
version = "6.0.1"
description = "Bulk downloader for multiple file hosts"
authors = ["Jacob B <[email protected]>"]
readme = "README.md"
repository = "https://github.com/jbsparrow/CyberDropDownloader"
description = "Bulk downloader for multiple file hosts"
documentation = "https://script-ware.gitbook.io/cyberdrop-dl/"
packages = [{ include = "cyberdrop_dl" }]
include = ["CHANGELOG.md"]
packages = [{include = "cyberdrop_dl"}]
readme = "README.md"
repository = "https://github.com/jbsparrow/CyberDropDownloader"
version = "6.0.1"

[tool.poetry.dependencies]
python = ">=3.11,<3.14"
Expand All @@ -24,15 +24,15 @@ certifi = "^2024.12.14"
filedate = "^3.0"
get-video-properties = "^0.1.1"
inquirerpy = "^0.3.4"
jeepney = [{platform = "linux", version = "^0.8.0"},{platform = "bsd", version = "^0.8.0"}]
jeepney = [{platform = "bsd", version = "^0.8.0"}, {platform = "linux", version = "^0.8.0"}]
mediafire = "^0.6.1"
myjdapi = "^1.1.7"
pillow = "^11.0.0"
platformdirs = "^4.3.6"
pycryptodomex = "^3.21.0"
pydantic = "^2.10.4"
pywin32 = {platform = "win32", version = "^308"}
pyyaml = "^6.0.2"
pywin32 = {version = "^308", platform = "win32"}
rich = "^13.9.4"
send2trash = "^1.8.3"
xxhash = "^3.5.0"
Expand All @@ -53,42 +53,64 @@ cyberdrop-dl = "cyberdrop_dl.main:main"
[tool.poetry.urls]
Changelog = "https://github.com/jbsparrow/CyberDropDownloader/blob/master/CHANGELOG.md"

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "module"
asyncio_mode = "auto"
minversion = "8.3"
testpaths = ["tests"]

[tool.ruff]
exclude = ["cyberdrop_dl/dependencies/browser_cookie3/__init__.py"]
line-length = 120
target-version = "py311"
exclude = ["cyberdrop_dl/dependencies/browser_cookie3/__init__.py"]

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"N", # PEP8 naming conventions
"TCH", # flake8-type-checking
"COM8", # flake8-commas linter
"ASYNC", # async calls that do not await anything or use blocking methods
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"COM8", # flake8-commas linter
"E", # pycodestyle errors
"F", # pyflakes
"FA102", # future annotations
"I", # isort
"N", # PEP8 naming conventions
"PTH", # use pathlib instead of os
"Q", # flake8-quotes
"RUF", # RUF specific fixes
"Q", # flake8-quotes
"T20", # flake8-print
"TC", # flake8-type-checking
"TID", # flake8-tidy-imports
"UP", # pyupgrade
"W" # pycodestyle warnings
]
extend-safe-fixes = [
"TC" # move import from and to TYPE_CHECKING blocks
]

ignore = [
"N806", # Uppercase variables in functions
"E501", # Suppress line-too-long, let formatter decide
"COM812", # missing-trailing-comma
"COM812", # missing-trailing-comma
"E501", # suppress line-too-long, let formatter decide
"N806" # uppercase variables in functions
]
unfixable = [
"ERA" # do not autoremove commented out code
]

[tool.pytest.ini_options]
minversion = "8.3"
testpaths = ["tests"]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "module"
[tool.ruff.lint.per-file-ignores]
"**/{tests,docs}/*" = ["E402", "T20"] # imports not at the top of the file.
"__init__.py" = ["E402"] # imports not at the top of the file.

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.tomlsort]
all = true
ignore_case = true
in_place = true
sort_first = ["name", "python", "select", "tool"]
spaces_before_inline_comment = 2
spaces_indent_inline_array = 4

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]

0 comments on commit 30a03db

Please sign in to comment.