forked from streamlit/streamlit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.ruff.toml
More file actions
138 lines (128 loc) · 5.85 KB
/
.ruff.toml
File metadata and controls
138 lines (128 loc) · 5.85 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2025)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# In addition to the standard set of exclusions, omit all tests:
extend-exclude = [
# Autogenerated files:
"lib/streamlit/proto",
"lib/streamlit/emojis.py",
"lib/streamlit/material_icon_names.py",
# File with an expected compilation error:
"e2e_playwright/compilation_error_dialog.py",
# Ignore frontend directory:
"frontend/**",
]
target-version = 'py39'
line-length = 88
[format]
docstring-code-format = true
docstring-code-line-length = "dynamic"
line-ending = "lf"
[lint]
select = [
"ASYNC", # Opinionated linting for asyncio.
"B", # flake8-bugbear
"C4", # Helps you write better list/set/dict comprehensions.
"D", # Check docstrings.
"E", # pycodestyle errors
"F", # pyflakes
"FA", # Verifies files use from __future__ import annotations if a type is used in the module that can be rewritten using PEP 563.
"FIX", # Only allow todo comments in the codebase.
"FLY", # Checks for bad usage of string join.
"FURB", # Rules to refurbish and modernize Python codebases.
"G", # Better usage of built-in logging
"I", # isort - Import sorting
"ICN", # Checks import naming conventions.
"INT", # Checks wrong usage of gettext module.
"INP", # Checks implicit namespace packages.
"ISC", # Encourage correct string literal concatenation.
"LOG", # Checks for issues using the standard library logging module.
"NPY", # Linting rules for numpy
"PD", # Opinionated linting for pandas.
"PERF", # Rules to prevent performance anti-patterns.
"PGH", # Pygrep hook rules.
"PIE", # Rules to prevent unnecessary code logic.
"PLC", # pycodestyle conventions
"PLE", # Pylint error rules.
"PLW", # Pylint warning rules
"PYI", # Linting rules for type annotations.
"Q", # Linting rules for quotes.
"RUF100", # Unused noqa directive
"S324", # Check usage of insecure hashlib functions.
"SLOT", # Enforces usage of slots.
"T10", # Check for debugger statements.
"T20", # Check for Print statements in python files.
"TC", # Linting for type-checking imports & forward references.
"TD", # Checks correct usage of TODO comments.
"TID", # Helps you write tidier imports.
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # Checks wrong usage of sys.version / sys.version_info.
]
ignore = [
"B008", # Checks for function calls in default function arguments.
"B904", # Checks for raise statements in exception handlers that lack a from clause.
"E501", # Checks for lines that exceed the specified maximum character length.
"ISC001", # Checks for implicitly concatenated strings on a single line.
"NPY002", # Checks for the use of legacy np.random function calls.
"PYI036", # Checks for incorrect function signatures on __exit__ and __aexit__ methods.
"PYI041", # Checks for parameter annotations that contain redundant unions between builtin numeric types (e.g., int | float).
"PYI051", # Checks for redundant unions between a Literal and a builtin supertype of that Literal.
"UP031", # Checks for printf-style string formatting, and offers to replace it with str.format calls.
"PLC0208", # Checks for iterations over set literals.
"G004", # Checks for usage of f-strings in logging messages.
"PD901", # Checks for usage of `df` variable name.
"PIE790", # Checks for unnecessary pass statements.
"TD003", # Checks for missing issue link in TODO comment.
"TD002", # Checks for missing author in TODO comment.
"D100", # Checks for missing docstring in public module.
"D101", # Checks for missing docstring in public class.
"D102", # Checks for missing docstring in public method.
"D103", # Checks for missing docstring in public function.
"D104", # Checks for missing docstring in public package.
"D105", # Checks for missing docstring in magic method.
"D106", # Checks for missing docstring in public nested class.
"D107", # Checks for missing docstring in __init__.
"D205", # Checks for missing blank line after docstring summary.
"D401", # Checks for docstring to start with imperative mood.
"D202", # Checks for no-blank line after docstring.
"FIX002", # Checks todo comments (which we want to allow).
"PGH003", # Checks for blanket type ignore.
]
exclude = [
# pympler is a vendored dependency that doesn't conform to our linting rules:
"lib/streamlit/vendor/**",
]
[lint.per-file-ignores]
"e2e_playwright/**" = ["T20", "B018", "PD", "PERF"]
"lib/streamlit/__init__.py" = ["E402", "PLC0414"]
"lib/setup.py" = ["INP"]
"lib/tests/**" = ["PD", "D", "INP", "PERF"]
"scripts/**" = ["T20", "INP", "PERF"]
".github/**" = ["T20", "INP", "PERF"]
[lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
[lint.isort]
known-first-party = ["streamlit", "shared", "tests", "e2e_playwright"]
[lint.pydocstyle]
convention = "numpy"
[lint.pycodestyle]
# E501 is currently deactivated, but suggested to be activated
# by developers via VS Code settings.
# Allow lines (e.g. comments) up to 120 characters instead of 88,
# which works well with Github.
max-line-length = 120
[lint.flake8-comprehensions]
# Allow dict calls that make use of keyword arguments (e.g., dict(a=1, b=2)).
allow-dict-calls-with-keyword-arguments = true