Skip to content

Instantly share code, notes, and snippets.

@serjflint
Created July 24, 2025 13:56
Show Gist options
  • Save serjflint/aad7f28baf2c8203ff1b92552403d8e6 to your computer and use it in GitHub Desktop.
Save serjflint/aad7f28baf2c8203ff1b92552403d8e6 to your computer and use it in GitHub Desktop.
backend-py3 config
[tool.ruff]
target-version = "py312"
line-length = 120
extend-exclude = [
]
namespace-packages = [
]
src = [
]
[tool.ruff.format]
preview = true
quote-style = "single"
indent-style = "space"
line-ending = "lf"
skip-magic-trailing-comma = false
docstring-code-format = false
docstring-code-line-length = "dynamic"
[tool.ruff.lint]
preview = true
select = [
"A001", # builtin-variable-shadowing
"ASYNC115", # async-zero-sleep
"B002", # unary-prefix-increment-decrement
"B006", # mutable-argument-default
"B009", # get-attr-with-constant
"B010", # set-attr-with-constant
# "B011", # assert-false, our python is not optimized
"B012", # jump-statement-in-finally
"B013", # redundant-tuple-in-exception-handler
"B014", # duplicate-handler-exception
"B018", # useless-expression
"B019", # cached-instance-method
"B023", # function-uses-loop-variable
"B026", # star-arg-unpacking-after-keyword-arg
"B028", # no-explicit-stacklevel
"B033", # duplicate-value
# "B904", # raise-without-from-inside-except, too big diff, no fix
"B905", # zip-without-explicit-strict
"BLE001", # blind-except
"C400", # unnecessary-generator-list
"C401", # unnecessary-generator-set
"C402", # unnecessary-generator-dict
"C403", # unnecessary-list-comprehension-set
"C404", # unnecessary-list-comprehension-dict
"C405", # unnecessary-literal-set
"C406", # unnecessary-literal-dict
# "C408", # unnecessary-collection-call, too big diff, unsafe fix
"C409", # unnecessary-literal-within-tuple-call
"C410", # unnecessary-literal-within-list-call
"C411", # unnecessary-list-call
"C413", # unnecessary-call-around-sorted
"C414", # unnecessary-double-cast-or-process
# "C416", # unnecessary-comprehension, too big diff, unsafe fix
# "C417", # unnecessary-map, too big diff, Fix is sometimes available.
"C418", # unnecessary-literal-within-dict-call
# "C419", # unnecessary-comprehension-in-call, too big diff, Fix is sometimes available.
# "COM812", # missing-trailing-comma, conflict with formatter
"COM818", # trailing-comma-on-bare-tuple
"COM819", # prohibited-trailing-comma
"D", # pydocstyle
"E101", # mixed-spaces-and-tabs
"E111", # indentation-with-invalid-multiple
"E112", # no-indented-block
"E113", # unexpected-indentation
"E114", # indentation-with-invalid-multiple-comment
"E115", # no-indented-block-comment
"E116", # unexpected-indentation-comment
"E117", # over-indented
"E201", # whitespace-after-open-bracket
"E202", # whitespace-before-close-bracket
"E203", # whitespace-before-punctuation
"E204", # whitespace-after-decorator
"E211", # whitespace-before-parameters
"E221", # multiple-spaces-before-operator
"E222", # multiple-spaces-after-operator
"E223", # tab-before-operator
"E224", # tab-after-operator
"E225", # missing-whitespace-around-operator
"E226", # missing-whitespace-around-arithmetic-operator
"E227", # missing-whitespace-around-bitwise-or-shift-operator
"E228", # missing-whitespace-around-modulo-operator
"E231", # missing-whitespace
"E241", # multiple-spaces-after-comma
"E242", # tab-after-comma
"E251", # unexpected-spaces-around-keyword-parameter-equals
"E252", # missing-whitespace-around-parameter-equals
"E261", # too-few-spaces-before-inline-comment
"E262", # no-space-after-inline-comment
"E265", # no-space-after-block-comment
"E266", # multiple-leading-hashes-for-block-comment
"E271", # multiple-spaces-after-keyword
"E272", # multiple-spaces-before-keyword
"E273", # tab-after-keyword
"E274", # tab-before-keyword
"E275", # missing-whitespace-after-keyword
"E301", # blank-line-between-methods
"E302", # blank-lines-top-level
"E303", # too-many-blank-lines
"E304", # blank-line-after-decorator
"E305", # blank-lines-after-function-or-class
"E306", # blank-lines-before-nested-definition
"E401", # multiple-imports-on-one-line
"E402", # module-import-not-at-top-of-file
# "E501", # line-too-long, conflict with formatter
"E502", # redundant-backslash
"E701", # multiple-statements-on-one-line-colon
"E702", # multiple-statements-on-one-line-semicolon
"E703", # useless-semicolon
"E711", # none-comparison
"E712", # true-false-comparison
"E713", # not-in-test
"E714", # not-is-test
"E721", # type-comparison
"E722", # bare-except
"E731", # lambda-assignment
"E741", # ambiguous-variable-name
"E742", # ambiguous-class-name
"E743", # ambiguous-function-name
"E902", # io-error
"EXE004", # shebang-leading-whitespace
"F401", # unused-import
"F402", # import-shadowed-by-loop-var
"F403", # undefined-local-with-import-star
"F404", # late-future-import
"F405", # undefined-local-with-import-star-usage
"F406", # undefined-local-with-nested-import-star-usage
"F407", # future-feature-not-defined
"F501", # percent-format-invalid-format
"F502", # percent-format-expected-mapping
"F503", # percent-format-expected-sequence
"F504", # percent-format-extra-named-arguments
"F505", # percent-format-missing-argument
"F506", # percent-format-mixed-positional-and-named
"F508", # percent-format-star-requires-sequence
"F509", # percent-format-unsupported-format-character
"F507", # percent-format-positional-count-mismatch
"F521", # string-dot-format-invalid-format
"F522", # string-dot-format-extra-named-arguments
"F523", # string-dot-format-extra-positional-arguments
"F524", # string-dot-format-missing-arguments
"F525", # string-dot-format-mixing-automatic
"F541", # f-string-missing-placeholders
"F601", # multi-value-repeated-key-literal
"F602", # multi-value-repeated-key-variable
"F621", # expressions-in-star-assignment
"F622", # multiple-starred-expressions
"F631", # assert-tuple
"F632", # is-literal
"F633", # invalid-print-syntax
"F634", # if-tuple
"F701", # break-outside-loop
"F702", # continue-outside-loop
"F704", # yield-outside-function
"F706", # return-outside-function
"F707", # default-except-not-last
"F722", # forward-annotation-syntax-error
"F811", # redefined-while-unused
"F821", # undefined-name
"F822", # undefined-export
"F823", # undefined-local
"F841", # unused-variable
"F842", # unused-annotation
"F901", # raise-not-implemented
"FA102", # future-required-type-annotation
"FAST001", # fast-api-redundant-response-model
"FLY002", # static-join-to-f-string
"FURB122", # for-loop-writes
"FURB129", # readlines-in-for
"FURB132", # check-and-remove-from-set
"FURB142", # for-loop-set-mutations
"FURB154", # repeated-global
"FURB157", # verbose-decimal-constructor
"FURB161", # bit-count
"FURB162", # fromisoformat-replace-z
"FURB166", # int-on-sliced-str
"FURB167", # regex-flag-alias
"FURB169", # type-none-comparison
"FURB180", # meta-class-abc-meta
"FURB187", # list-reverse-copy
"FURB188", # slice-to-remove-prefix-or-suffix
"G001", # logging-string-format
"G002", # logging-percent-format
"G010", # logging-warn
"I001", # unsorted-imports
"I002", # missing-required-import
# "ISC001", # auto-fix doesn't cover all cases https://github.com/astral-sh/ruff/issues/13063
"ISC002", # multi-line-implicit-string-concatenation
"ISC003", # explicit-string-concatenation
"N804", # invalid-first-argument-name-for-class-method
"N804", # invalid-first-argument-name-for-class-method
"N805", # invalid-first-argument-name-for-method
"N815", # mixed-case-variable-in-class-scope
"N999", # invalid-module-name
"PERF101", # unnecessary-list-cast
"PERF102", # incorrect-dict-iterator
"PIE790", # unnecessary-placeholder
"PIE794", # duplicate-class-field-definition
"PIE808", # unnecessary-range-start
"PIE810", # multiple-starts-ends-with
"PLC0105", # type-name-incorrect-variance
"PLC0132", # type-param-name-mismatch
"PLC0205", # single-string-slots
"PLC0206", # dict-index-missing-items
"PLC0208", # iteration-over-set
"PLC0414", # useless-import-alias
"PLC0415", # import-outside-top-level
"PLC1802", # len-test
"PLC2401", # non-ascii-name
"PLC2403", # non-ascii-import-name
"PLC2801", # unnecessary-dunder-call
"PLC3002", # unnecessary-direct-lambda-call
"PLE0100", # yield-in-init
"PLE0101", # return-in-init
"PLE0115", # nonlocal-and-global
"PLE0116", # continue-in-finally
"PLE0117", # nonlocal-without-binding
"PLE0118", # load-before-global-declaration
"PLE0237", # non-slot-assignment
"PLE0241", # duplicate-bases
"PLE0302", # unexpected-special-method-signature
"PLE0303", # invalid-length-return-type
"PLE0304", # invalid-bool-return-type
"PLE0305", # invalid-index-return-type
"PLE0307", # invalid-str-return-type
"PLE0308", # invalid-bytes-return-type
"PLE0309", # invalid-hash-return-type
"PLE0604", # invalid-all-object
"PLE0605", # invalid-all-format
"PLE0643", # potential-index-error
"PLE0704", # misplaced-bare-raise
"PLE1132", # repeated-keyword-argument
"PLE1141", # dict-iter-missing-items
"PLE1142", # await-outside-async
"PLE1205", # logging-too-many-args
"PLE1206", # logging-too-few-args
"PLE1300", # bad-string-format-character
"PLE1307", # bad-string-format-type
"PLE1310", # bad-str-strip-call
"PLE1507", # invalid-envvar-value
"PLE1519", # singledispatch-method
"PLE1520", # singledispatchmethod-function
"PLE1700", # yield-from-in-async-function
"PLE2502", # bidirectional-unicode
"PLE2510", # invalid-character-backspace
"PLE2512", # invalid-character-sub
"PLE2513", # invalid-character-esc
"PLE2514", # invalid-character-nul
"PLE2515", # invalid-character-zero-width-space
"PLE4703", # modified-iterating-set
"PLR0124", # comparison-with-itself
"PLR0133", # comparison-of-constant
"PLR0202", # no-classmethod-decorator
"PLR0203", # no-staticmethod-decorator
"PLR0206", # property-with-parameters
"PLR0402", # manual-from-import
"PLR0916", # too-many-boolean-expressions
# "PLR1701", # has been remapped to `SIM101`
"PLR1702", # too-many-nested-blocks
"PLR1704", # redefined-argument-from-local
"PLR1711", # useless-return
"PLR1714", # repeated-equality-comparison
"PLR1716", # boolean-chained-comparison
"PLR1722", # sys-exit-alias
"PLR1730", # if-stmt-min-max
"PLR1733", # unnecessary-dict-index-lookup
"PLR1736", # unnecessary-list-index-lookup
"PLR2044", # empty-comment
"PLR6104", # non-augmented-assignment
# "PLR6201", # literal-membership, too big diff
"PLW0108", # unnecessary-lambda
"PLW0120", # useless-else-on-loop
"PLW0127", # self-assigning-variable
"PLW0128", # redeclared-assigned-name
"PLW0129", # assert-on-string-literal
"PLW0131", # named-expr-without-context
"PLW0133", # useless-exception-statement
"PLW0177", # nan-comparison
"PLW0211", # bad-staticmethod-argument
"PLW0245", # super-without-brackets
"PLW0406", # import-self
"PLW0602", # global-variable-not-assigned
"PLW0603", # global-statement
"PLW0604", # global-at-module-level
"PLW0711", # binary-op-exception
"PLW1501", # bad-open-mode
"PLW1507", # shallow-copy-environ
"PLW1508", # invalid-envvar-default
"PLW1509", # subprocess-popen-preexec-fn
"PLW1510", # subprocess-run-without-check
"PLW1514", # unspecified-encoding
"PLW2101", # useless-with-lock
"PLW3301", # nested-min-max
"PT001", # pytest-fixture-incorrect-parentheses-style
"PT003", # pytest-extraneous-scope-function
"PT022", # pytest-useless-yield-fixture
"PT023", # pytest-incorrect-mark-parentheses-style
"PT024", # pytest-unnecessary-asyncio-mark-on-fixture
"PT025", # pytest-erroneous-use-fixtures-on-fixture
"PT026", # pytest-use-fixtures-without-parameters
"PTH201", # path-constructor-current-directory
"PYI009", # pass-statement-stub-body
"PYI010", # non-empty-stub-body
"PYI011", # typed-argument-default-in-stub
"PYI012", # pass-in-class-body
"PYI014", # argument-default-in-stub
"PYI015", # assignment-default-in-stub
"PYI020", # quoted-annotation-in-stub
"PYI021", # docstring-in-stub
"PYI026", # type-alias-without-annotation
"PYI029", # str-or-repr-defined-in-stub
"PYI032", # any-eq-ne-annotation
"PYI053", # string-or-bytes-too-long
"PYI054", # numeric-literal-too-long
"PYI062", # duplicate-literal-member
"Q000", # bad-quotes-inline-string
"Q001", # bad-quotes-multiline-string
"Q003", # avoidable-escaped-quote
"Q004", # unnecessary-escaped-quote
"RET501", # unnecessary-return-none
"RET502", # implicit-return-value
# "RET503", # implicit-return, too big diff
# "RET504", # unnecessary-assign, too big diff
"RET505", # superfluous-else-return
"RET506", # superfluous-else-raise
"RET507", # superfluous-else-continue
"RET508", # superfluous-else-break
# "RSE102", # unnecessary-paren-on-raise-exception, too big diff
"RUF010", # explicit-f-string-type-conversion
"RUF015", # unnecessary-iterable-allocation-for-first-element
"RUF017", # quadratic-list-summation
"RUF019", # unnecessary-key-check
"RUF020", # never-union
"RUF021", # parenthesize-chained-operators
"RUF027", # missing-f-string-syntax
"RUF028", # invalid-formatter-suppression-comment
"RUF030", # assert-with-print-message
# "RUF032", # decimal-from-float-literal, too big diff, unsafe fix
"RUF046", # unnecessary-cast-to-int
"RUF051", # if-key-in-dict-del
"RUF057", # unnecessary-round
# "RUF100", # unused-noqa, conflicts with flake8
"RUF101", # redirected-noqa
"S102", # exec-builtin
"S307", # suspicious-eval-usage
"SIM101", # duplicate-isinstance-call
"SIM108", # if-else-block-instead-of-if-exp
"SIM109", # compare-with-tuple
"SIM113", # enumerate-for-loop
"SIM115", # open-file-with-context-handler
# "SIM118", # in-dict-keys, too big diff
"SIM201", # negate-equal-op
"SIM202", # negate-not-equal-op
"SIM208", # double-negation
"SIM210", # if-expr-with-true-false
"SIM211", # if-expr-with-false-true
"SIM212", # if-expr-with-twisted-arms
"SIM220", # expr-and-not-expr
"SIM221", # expr-or-not-expr
"SIM222", # expr-or-true
"SIM223", # expr-and-false
"SIM401", # if-else-block-instead-of-dict-get
"SIM910", # dict-get-with-none-default
"SIM911", # zip-dict-keys-and-values
# "SLF001", # private-member-access, too big diff
"T100", # debugger
"TC005", # empty-type-checking-block
"TD006", # invalid-todo-capitalization
"TID252", # relative-imports
# "TRY002", # raise-vanilla-class, too big diff
"TRY201", # verbose-raise
"TRY203", # useless-try-except
"UP001", # useless-metaclass-type
"UP004", # useless-object-inheritance
"UP005", # deprecated-unittest-alias
"UP008", # super-call-with-parameters
"UP009", # utf8-encoding-declaration
"UP010", # unnecessary-future-import
"UP011", # lru-cache-without-parameters
"UP012", # unnecessary-encode-utf8
"UP015", # redundant-open-modes
"UP018", # native-literals
"UP021", # replace-universal-newlines
"UP023", # deprecated-c-element-tree
"UP024", # os-error-alias
"UP025", # unicode-kind-prefix
"UP026", # deprecated-mock-import
# "UP027", # unpacked-list-comprehension # removed
"UP028", # yield-in-for-loop
"UP029", # unnecessary-builtin-import
# "UP031", # printf-string-formatting # consider-using-f-string
"UP033", # lru-cache-with-maxsize-none
"UP034", # extraneous-parentheses
"UP037", # quoted-annotation
# "UP038", # non-pep604-isinstance # deprecated
"UP039", # unnecessary-class-parentheses
"UP040", # non-pep695-type-alias
"UP041", # timeout-error-alias
"UP043", # unnecessary-default-type-args
"UP044", # non-pep646-unpack
"UP047", # non-pep695-generic-function
"W191", # tab-indentation
"W291", # trailing-whitespace
"W292", # missing-newline-at-end-of-file
"W293", # blank-line-with-whitespace
"W391", # too-many-newlines-at-end-of-file
"W605", # invalid-escape-sequence
"DTZ001", # call-datetime-without-tzinfo
"DTZ002", # call-datetime-today
"DTZ003", # call-datetime-utcnow
"DTZ004", # call-datetime-utcfromtimestamp
"DTZ005", # call-datetime-now-without-tzinfo
"DTZ006", # call-datetime-fromtimestamp
"DTZ007", # call-datetime-strptime-without-zone
"DTZ011", # call-date-today
"DTZ012", # call-date-fromtimestamp
"DTZ901", # datetime-min-max
]
ignore = [
"D100",
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"D200",
"D205",
"D212",
"D415",
]
unfixable = [
"N805",
"SIM108",
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "single"
multiline-quotes = "double"
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"classmethod",
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
"pydantic.validator",
"pydantic.root_validator",
# Allow SQLAlchemy's dynamic decorators, like `@field.expression`, to trigger class method treatment.
"declared_attr",
"expression",
"comparator",
]
[lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
[tool.ruff.lint.isort]
force-single-line = true
# TODO(serjflint)
# relative-imports-order = "furthest-to-closest"
relative-imports-order = "closest-to-furthest"
force-sort-within-sections = true
case-sensitive = false
order-by-type = false
# FIXME: https://github.com/astral-sh/ruff/issues/10927
# detect-same-package = true
# FIXME: https://github.com/astral-sh/ruff/issues/10926
# force-to-top = ["*.pytest_init"]
# TODO(serjflint)
# required-imports = ["from __future__ import annotations"]
section-order = [
"future",
"standard-library",
"third-party",
"appnexus",
"first-party",
"local-folder",
]
no-lines-before = [
"local-folder",
]
# FIXME: https://github.com/astral-sh/ruff/issues/10989
known-third-party = [
"pytest",
"yaml",
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment