Skip to content

Instantly share code, notes, and snippets.

@GreyElaina
Last active February 5, 2025 06:19
Show Gist options
  • Save GreyElaina/416f65e3141a26ab6603ba23c92bb816 to your computer and use it in GitHub Desktop.
Save GreyElaina/416f65e3141a26ab6603ba23c92bb816 to your computer and use it in GitHub Desktop.
My Ruff Config
[tool.ruff]
line-length = 135
[tool.ruff.lint]
select = [
"F", # pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"I", # isort
"N", # PEP8-naming
"UP", # pyupgrade
"YTT", # flake8-2020
"ASYNC", # flake8-async
"S", # flake8-bandit
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
"T20", # flake8-print
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"TID", # flake8-tidy-imports
"TC", # flake8-type-checking
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
# "ERA", # eradicate
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PL", # pylint
"TRY", # tryceratops
"FLY", # flynt
"FAST", # FastAPI
"PERF", # Perflint
"FURB", # refurb
"RUF", # Ruff-specific rules
]
ignore = [
"E501", # 过长的行由 ruff format 处理, 剩余的都是字符串
"UP035", # pyupgrade, 但 typing.Callable 的导入会报错
"TRY003",
"TRY301", # 为啥非要把 raise 丢进另外一个 inner fn 里
"BLE001", # except Exception as e
"PGH003", # 要求 `# type: ignore` 提供理由,但 pyright 和 mypy 等都不是统一标准。
"PLC0414", # 用 import-as 表示 re-export
"N818", # 要求所有自定义错误以 Error 作后缀,但我们不这么做
"RET502", # return = return None
"RET503", # 就要 implicit return none
"PLC0105", # 我们已经用 R 表示协变,Q 表示逆变了
"PLR0913", # 参数就那么多的,你用 builder 什么的不是更逆天?
"SIM108", # 迫真 simplicy
"RUF009", # 我不想要额外的全局变量。
"UP038", # instance(..., X | Y) 还是太超前了
"RUF003", # 中文注释里用全角符号怎么你了
"SLOT000", # 动态类型需求,主要是 json5 backend
"PLR0911", "PLR0912", "PLR0915", # 复杂度高点怎么你了
"PYI041", # int 和 float 在运行时的类型没有交集(互不成立 issubclass)
"PLW2901", # shallow 怎么你了
"S101", # assert 怎么你了,非要 RuntimeError 吗
"PLR2004", # magic number 怎么你了
"TRY004", # 我要抛啥错误我清楚
"COM812", # 强制尾随逗号
"TID252", # 相对导入
"ISC001", # format warning
]
flake8-quotes = { inline-quotes = "double", multiline-quotes = "double" }
[tool.ruff.lint.flake8-annotations]
mypy-init-return = true
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["id"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment