veops / cmdb

CMDB: configuration and management of IT resources
https://veops.cn/cmdb
GNU Affero General Public License v3.0
1.48k stars 384 forks source link

[Feature]: 开发好哥哥,要不要引入ruff和pre-commit呢?不复杂,但能提升代码可读性 #612

Closed iridescentGray closed 1 month ago

iridescentGray commented 2 months ago

Contact Details

colorfulgray0@gmail.com

feature is related to UI or API aspects?

API

What is your advice?

.pre-commit-config.yaml

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: check-added-large-files
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml

  - repo: https://github.com/charliermarsh/ruff-pre-commit
    rev: v0.5.7
    hooks:
      - id: ruff
        args:
          # https://github.com/astral-sh/ruff-pre-commit/issues/64
          - '--config'
          - './.ruff.toml'
          - '--fix'
          - '--unsafe-fixes'
      - id: ruff-format

.ruff.toml

line-length = 120
cache-dir = ".ruff_cache"
target-version = "py310"
unsafe-fixes = true
show-fixes = true

[lint]
select = [
    "E",
    "F",
    "I",
    "TCH",
    # W
    "W505",
    # PT
    "PT018",
    # SIM
    "SIM101",
    "SIM114",
    # PGH
    "PGH004",
    # PL
    "PLE1142",
    # RUF
    "RUF100",
    # UP
    "UP007"
]
preview = true
ignore = ["FURB101"]

[lint.flake8-pytest-style]
mark-parentheses = false
parametrize-names-type = "list"
parametrize-values-row-type = "list"
parametrize-values-type = "tuple"

[lint.flake8-unused-arguments]
ignore-variadic-names = true

[lint.isort]
lines-between-types = 1
order-by-type = true

[lint.per-file-ignores]
"**/api/v1/*.py" = ["TCH"]
"**/model/*.py" = ["TCH003"]
"**/model/__init__.py" = ["F401"]
"**/tests/*.py" = ["E402"]

[format]
preview = true
quote-style = "single"
docstring-code-format = true
skip-magic-trailing-comma = false

Version

newest