forked from modular/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
141 lines (126 loc) · 4.78 KB
/
pyproject.toml
File metadata and controls
141 lines (126 loc) · 4.78 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
139
140
141
[project]
name = "modular"
version = "0"
requires-python = ">= 3.10"
# TODO: restrict utils/packaging/conda/test_inputs to only test_format.mojo
[tool.black]
include = '\.mojo$'
line-length = 80
preview = true
fast = true
force-exclude = '''
(
/(
third-party/llvm-project
| third-party/vllm-benchmarks
| \.derived
| venv
| utils/mblack
| KGEN/test/mojo-parser
| KGEN/test/mojo-tool/format
| max/python/max/serve/schemas
| utils/packaging/conda/test_inputs
)/
)
'''
[tool.ruff]
line-length = 80 # Must match above
src = ["something-that-doesnt-exist"] # Stop ruff from assuming any root directory is a python module
extend-exclude = [
"**/lit.cfg.py", # Globals that aren't imported
"*.ipynb",
"*max/serve/schemas/openai.py", # Generated file
"third-party",
"bazel/internal/llvm-lit/lit.common.cfg.py", # Globals that aren't imported
"utils/mblack",
]
[tool.ruff.lint]
ignore = [
"ANN002", # TODO: Missing type annotation for *args
"ANN003", # TODO: Missing type annotation for **kwargs
"ANN204", # TODO: Missing return type annotation for special method
"ANN401", # TODO: Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
"B008", # Do not perform function call in argument defaults
"B017", # Do not assert blind exception: `Exception`
"B028", # No explicit `stacklevel` keyword argument found
"D100", # TODO: Enable missing docstrings in public modules
"D101", # TODO: Enable missing docstrings in public classes
"D103", # TODO: Enable missing docstrings in public functions
"D104", # TODO: Enable missing docstrings in public packages
"D105", # undocumented-magic-method
"E402", # TODO: import top of file
"E722", # bare except
"E731", # TODO: Don't assign lambda
"E741", # TODO: Ambiguous variable name
"F403", # glob imports
"F405", # TODO: glob imports undefined
"F821", # TODO: Undefined names, means script is invalid
"F841", # TODO: unused variables
"FURB122", # Questionable readability improvement
"RUF005", # Consider iterable unpacking instead of concatenation
"RUF010", # Use explicit conversion flag
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF015", # Prefer `next(iter(iterable))` over single element slice
"SIM102", # Collapsible if
"SIM105", # Suppressible exception
"SIM108", # Use ternary operator
"SIM114", # Combine arms with or
"SIM115", # Use context manager for opening files
"SIM117", # Merge with statements
"SIM300", # YODA conditions
"SIM905", # Use a list literal instead of str.split
]
extend-select = [
"ANN", # Require function type annotations
"B", # Bugbear lints
"D", # Pydocstyle lints
"FURB", # Refurb lints for modernization
"I", # Import sorting lints
"RUF", # Ruff specific lints
"SIM", # Simplify lints
"T10", # Checks for the presence of debugger calls and imports.
"UP", # Type annotations should not use Union, Optional, etc
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Ignore unused imports being re-exported
# Slow rollout of pydocstyle lint:
# Enable docstring checks only for SDK modules in SDK/lib/API/python/ that currently pass all D rules.
# To add more modules to this list, test them with:
# ./bazelw run //open-source/max/bazel/lint:ruff.check -- --select=D --no-cache <file>
# and verify no errors are reported for that specific file.
"!max/python/max/{driver/__init__.py,driver/driver.py,driver/tensor.py,dtype/__init__.py,engine/__init__.py,engine/api.py,experimental/__init__.py,experimental/random.py,graph/__init__.py,graph/quantization.py,graph/weight.py,interfaces/context.py,interfaces/status.py,nn/embedding.py,nn/float8_config.py,nn/linear.py}" = ["D"]
# Ignore ANN001 (function argument missing type annotation) for auto-generated
# stubfiles
"*.pyi" = ["ANN001", "ANN201", "ANN202", "ANN205", "ANN206"]
# Disable lints which complain about weird unicode characters in files that include
# a large number of LLM test prompts.
"max/tests/integration/pipelines/python/test_common/test_data.py" = ["RUF001", "RUF003"]
[tool.mypy]
color_output = true
ignore_missing_imports = false
pretty = true
python_version = "3.10"
check_untyped_defs = true
warn_unused_ignores = true
follow_imports = "silent"
follow_imports_for_stubs = true
plugins = "pydantic.mypy"
[[tool.mypy.overrides]]
module = "torch.*"
follow_imports = "skip"
[[tool.mypy.overrides]]
module = "transformers.*"
follow_imports = "skip"
[[tool.mypy.overrides]]
module = "absl.*"
follow_imports = "skip"
[[tool.mypy.overrides]]
module = "max.*"
disallow_any_generics = true
# TODO: Ideally there would be no exception for max.experimental, but, well, it
# is experimental... Hopefully it graduates soon.
[[tool.mypy.overrides]]
module = "max.experimental.*"
disallow_any_generics = false