๐Ÿ“ฆ langgenius / dify

๐Ÿ“„ .ruff.toml ยท 119 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119exclude = [
    "migrations/*",
    ".git",
    ".git/**",
]
line-length = 120

[format]
quote-style = "double"

[lint]
preview = true
select = [
    "B",       # flake8-bugbear rules
    "C4",      # flake8-comprehensions
    "E",       # pycodestyle E rules
    "F",       # pyflakes rules
    "FURB",    # refurb rules
    "I",       # isort rules
    "N",       # pep8-naming
    "PT",      # flake8-pytest-style rules
    "PLC0208", # iteration-over-set
    "PLC0414", # useless-import-alias
    "PLE0604", # invalid-all-object
    "PLE0605", # invalid-all-format
    "PLR0402", # manual-from-import
    "PLR1711", # useless-return
    "PLR1714", # repeated-equality-comparison
    "RUF013",  # implicit-optional
    "RUF019",  # unnecessary-key-check
    "RUF100",  # unused-noqa
    "RUF101",  # redirected-noqa
    "RUF200",  # invalid-pyproject-toml
    "RUF022",  # unsorted-dunder-all
    "S506",    # unsafe-yaml-load
    "SIM",     # flake8-simplify rules
    "T201",    # print-found
    "TRY400",  # error-instead-of-exception
    "TRY401",  # verbose-log-message
    "UP",      # pyupgrade rules
    "W191",    # tab-indentation
    "W605",    # invalid-escape-sequence
    "G001",    # don't use str format to logging messages
    "G003",    # don't use + in logging messages
    "G004",    # don't use f-strings to format logging messages
    "UP042",   # use StrEnum,
    "S110",    # disallow the try-except-pass pattern.

    # security related linting rules
    # RCE proctection (sort of)
    "S102", # exec-builtin, disallow use of `exec`
    "S307", # suspicious-eval-usage, disallow use of `eval` and `ast.literal_eval`
    "S301", # suspicious-pickle-usage, disallow use of `pickle` and its wrappers.
    "S302", # suspicious-marshal-usage, disallow use of `marshal` module
    "S311", # suspicious-non-cryptographic-random-usage,

]

ignore = [
    "E402",    # module-import-not-at-top-of-file
    "E711",    # none-comparison
    "E712",    # true-false-comparison
    "E721",    # type-comparison
    "E722",    # bare-except
    "F821",    # undefined-name
    "F841",    # unused-variable
    "FURB113", # repeated-append
    "FURB152", # math-constant
    "UP007",   # non-pep604-annotation
    "UP032",   # f-string
    "UP045",   # non-pep604-annotation-optional
    "B005",    # strip-with-multi-characters
    "B006",    # mutable-argument-default
    "B007",    # unused-loop-control-variable
    "B026",    # star-arg-unpacking-after-keyword-arg
    "B901",    # allow return in yield
    "B903",    # class-as-data-structure
    "B904",    # raise-without-from-inside-except
    "B905",    # zip-without-explicit-strict
    "N806",    # non-lowercase-variable-in-function
    "N815",    # mixed-case-variable-in-class-scope
    "PT011",   # pytest-raises-too-broad
    "SIM102",  # collapsible-if
    "SIM103",  # needless-bool
    "SIM105",  # suppressible-exception
    "SIM107",  # return-in-try-except-finally
    "SIM108",  # if-else-block-instead-of-if-exp
    "SIM113",  # enumerate-for-loop
    "SIM117",  # multiple-with-statements
    "SIM210",  # if-expr-with-true-false
]

[lint.per-file-ignores]
"__init__.py" = [
    "F401", # unused-import
    "F811", # redefined-while-unused
]
"configs/*" = [
    "N802", # invalid-function-name
]
"core/model_runtime/callbacks/base_callback.py" = ["T201"]
"core/workflow/callbacks/workflow_logging_callback.py" = ["T201"]
"libs/gmpy2_pkcs10aep_cipher.py" = [
    "N803", # invalid-argument-name
]
"tests/*" = [
    "F811", # redefined-while-unused
    "T201", # allow print in tests,
    "S110", # allow ignoring exceptions in tests code (currently)

]

[lint.pyflakes]
allowed-unused-imports = [
    "_pytest.monkeypatch",
    "tests.integration_tests",
    "tests.unit_tests",
]