pytorch-lightning
/
pyproject.toml
284 строки · 10.6 Кб
1# Copyright The Lightning AI team.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15[metadata]
16name = "lightning"
17author = "Lightning-AI et al."
18url = "https://github.com/Lightning-AI/lightning"
19
20[build-system]
21requires = [
22"setuptools",
23"wheel",
24]
25
26
27[tool.black]
28line-length = 120
29exclude = '(_notebooks/.*)'
30
31[tool.docformatter]
32recursive = true
33# this need to be shorter as some docstings are r"""...
34wrap-summaries = 119
35wrap-descriptions = 120
36blank = true
37
38[tool.codespell]
39# Todo: enable also python files in a next step
40skip = '*.py'
41quiet-level = 3
42# comma separated list of words; waiting for:
43# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603
44# also adding links until they ignored by its: nature
45# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960
46ignore-words-list = "te, compiletime"
47
48
49[tool.ruff]
50line-length = 120
51# Enable Pyflakes `E` and `F` codes by default.
52lint.select = [
53"E", "W", # see: https://pypi.org/project/pycodestyle
54"F", # see: https://pypi.org/project/pyflakes
55"S", # see: https://pypi.org/project/flake8-bandit
56"RUF018", # see: https://docs.astral.sh/ruff/rules/assignment-in-assert
57]
58lint.extend-select = [
59"I", # see: isort
60"C4", # see: https://pypi.org/project/flake8-comprehensions
61"SIM", # see: https://pypi.org/project/flake8-simplify
62"RET", # see: https://pypi.org/project/flake8-return
63"PT", # see: https://pypi.org/project/flake8-pytest-style
64"RUF100", # see: https://docs.astral.sh/ruff/rules/unused-noqa/
65]
66lint.ignore = [
67"E731", # Do not assign a lambda expression, use a def
68"S108",
69"E203", # conflicts with black
70]
71# Exclude a variety of commonly ignored directories.
72exclude = [
73".git",
74"docs",
75"_notebooks"
76]
77lint.ignore-init-module-imports = true
78
79[tool.ruff.lint.per-file-ignores]
80".actions/*" = ["S101", "S310"]
81"setup.py" = ["S101"]
82"examples/**" = [
83"S101", # Use of `assert` detected
84"S113", # todo: Probable use of requests call without
85"S104", # Possible binding to all interface
86"F821", # Undefined name `...`
87"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
88"S501", # Probable use of `requests` call with `verify=False` disabling SSL certificate checks
89"S108", # Probable insecure usage of temporary file or directory: "/tmp/data/MNIST"
90]
91"src/**" = [
92"S101", # todo: Use of `assert` detected
93"S105", "S106", "S107", # todo: Possible hardcoded password: ...
94"S113", # todo: Probable use of requests call without timeout
95"S301", # todo: `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
96"S324", # todo: Probable use of insecure hash functions in `hashlib`
97"S403", # todo: `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure
98"S404", # todo: `subprocess` module is possibly insecure
99"S602", # todo: `subprocess` call with `shell=True` identified, security issue
100"S603", # todo: `subprocess` call: check for execution of untrusted input
101"S605", # todo: Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
102"S607", # todo: Starting a process with a partial executable path
103"RET504", # todo:Unnecessary variable assignment before `return` statement
104"RET503",
105]
106"tests/**" = [
107"S101", # Use of `assert` detected
108"S105", "S106", # todo: Possible hardcoded password: ...
109"S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
110"S113", # todo: Probable use of requests call without timeout
111"S311", # todo: Standard pseudo-random generators are not suitable for cryptographic purposes
112"S108", # todo: Probable insecure usage of temporary file or directory: "/tmp/sys-customizations-sync"
113"S202", # Uses of `tarfile.extractall()`
114"S403", # `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure
115"S404", # `subprocess` module is possibly insecure
116"S602", # todo: `subprocess` call with `shell=True` identified, security issue
117"S603", # todo: `subprocess` call: check for execution of untrusted input
118"S605", # todo: Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell`
119"S607", # todo: Starting a process with a partial executable path
120"RET504", # todo:Unnecessary variable assignment before `return` statement
121"PT004", # todo: Fixture `tmpdir_unittest_fixture` does not return anything, add leading underscore
122"PT011", # todo: `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception
123"PT012", # todo: `pytest.raises()` block should contain a single simple statement
124"PT019", # todo: Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead
125]
126
127[tool.ruff.lint.mccabe]
128# Unlike Flake8, default to a complexity level of 10.
129max-complexity = 10
130
131
132[tool.mypy]
133files = [
134"src/lightning",
135]
136# This section is for folders with "-" as they are not valid python modules
137exclude = [
138"src/lightning/app/cli/app-template",
139"src/lightning/app/cli/component-template",
140"src/lightning/app/cli/pl-app-template",
141"src/lightning/app/cli/react-ui-template",
142]
143install_types = "True"
144non_interactive = "True"
145disallow_untyped_defs = "True"
146ignore_missing_imports = "True"
147show_error_codes = "True"
148warn_redundant_casts = "True"
149warn_unused_configs = "True"
150warn_unused_ignores = "True"
151allow_redefinition = "True"
152# disable this rule as the Trainer attributes are defined in the connectors, not in its __init__
153disable_error_code = "attr-defined"
154# style choices
155warn_no_return = "False"
156
157# Ignore mypy errors for these files
158# TODO: the goal is for this to be empty
159[[tool.mypy.overrides]]
160# the list can be generated with:
161# mypy --no-error-summary 2>&1 | tr ':' ' ' | awk '{print $1}' | sort | uniq | sed 's/\.py//g; s|src/||g; s|\/|\.|g' | xargs -I {} echo '"{}",'
162module = [
163"lightning.app.api.http_methods",
164"lightning.app.api.request_types",
165"lightning.app.cli.cmd_install",
166"lightning.app.cli.commands.app_commands",
167"lightning.app.cli.commands.cd",
168"lightning.app.cli.commands.cp",
169"lightning.app.cli.commands.ls",
170"lightning.app.cli.connect.app",
171"lightning.app.components.database.client",
172"lightning.app.components.database.server",
173"lightning.app.components.database.utilities",
174"lightning.app.components.multi_node.base",
175"lightning.app.components.multi_node.fabric",
176"lightning.app.components.multi_node.pytorch_spawn",
177"lightning.app.components.multi_node.trainer",
178"lightning.app.components.python.popen",
179"lightning.app.components.python.tracer",
180"lightning.app.components.serve.auto_scaler",
181"lightning.app.components.serve.gradio_server",
182"lightning.app.components.serve.python_server",
183"lightning.app.components.serve.serve",
184"lightning.app.components.serve.streamlit",
185"lightning.app.components.serve.types.image",
186"lightning.app.components.serve.types.type",
187"lightning.app.components.training",
188"lightning.app.frontend.panel.app_state_comm",
189"lightning.app.frontend.panel.app_state_watcher",
190"lightning.app.frontend.panel.panel_frontend",
191"lightning.app.frontend.panel.panel_serve_render_fn",
192"lightning.app.frontend.streamlit_base",
193"lightning.app.frontend.stream_lit",
194"lightning.app.frontend.utils",
195"lightning.app.frontend.web",
196"lightning.app.launcher.launcher",
197"lightning.app.launcher.lightning_backend",
198"lightning.app.launcher.lightning_hybrid_backend",
199"lightning.app.pdb.pdb",
200"lightning.app.runners.backends.backend",
201"lightning.app.runners.backends.cloud",
202"lightning.app.runners.backends.docker",
203"lightning.app.runners.backends.mp_process",
204"lightning.app.runners.cloud",
205"lightning.app.runners.multiprocess",
206"lightning.app.runners.runtime",
207"lightning.app.source_code.copytree",
208"lightning.app.source_code.hashing",
209"lightning.app.source_code.local",
210"lightning.app.source_code.tar",
211"lightning.app.source_code.uploader",
212"lightning.app.storage.copier",
213"lightning.app.storage.drive",
214"lightning.app.storage.filesystem",
215"lightning.app.storage.orchestrator",
216"lightning.app.storage.path",
217"lightning.app.storage.payload",
218"lightning.app.structures.dict",
219"lightning.app.structures.list",
220"lightning.app.testing.helpers",
221"lightning.app.testing.testing",
222"lightning.app.utilities.app_helpers",
223"lightning.app.utilities.app_logs",
224"lightning.app.utilities.cli_helpers",
225"lightning.app.utilities.cloud",
226"lightning.app.utilities.commands.base",
227"lightning.app.utilities.component",
228"lightning.app.utilities.enum",
229"lightning.app.utilities.exceptions",
230"lightning.app.utilities.git",
231"lightning.app.utilities.imports",
232"lightning.app.utilities.introspection",
233"lightning.app.utilities.layout",
234"lightning.app.utilities.load_app",
235"lightning.app.utilities.log_helpers",
236"lightning.app.utilities.login",
237"lightning.app.utilities.name_generator",
238"lightning.app.utilities.network",
239"lightning.app.utilities.openapi",
240"lightning.app.utilities.packaging.cloud_compute",
241"lightning.app.utilities.packaging.lightning_utils",
242"lightning.app.utilities.proxies",
243"lightning.app.utilities.scheduler",
244"lightning.app.utilities.state",
245"lightning.app.utilities.tracer",
246"lightning.app.utilities.tree",
247"lightning.store.utils",
248]
249ignore_errors = "True"
250
251
252[tool.coverage.report]
253exclude_lines = [
254"pragma: no cover",
255"warnings",
256"pass",
257"rank_zero_warn",
258"raise NotImplementedError",
259]
260
261
262[tool.pytest.ini_options]
263norecursedirs = [
264".git",
265".github",
266"dist",
267"build",
268"docs",
269]
270addopts = [
271"--strict-markers",
272"--doctest-modules",
273"--color=yes",
274"--disable-pytest-warnings",
275"--ignore=legacy/checkpoints",
276]
277markers = [
278"cloud: Run the cloud tests for example",
279]
280filterwarnings = [
281"error::FutureWarning",
282]
283xfail_strict = true
284junit_duration_report = "call"
285