forked from huggingface/transformers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
134 lines (124 loc) 路 6.61 KB
/
Copy pathpyproject.toml
File metadata and controls
134 lines (124 loc) 路 6.61 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
[tool.coverage.run]
source = ["transformers"]
omit = [
"*/convert_*",
"*/__main__.py"
]
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"raise",
"except",
"register_parameter"
]
[tool.ruff]
target-version = "py310"
line-length = 119
[tool.ruff.lint]
# `PLW1514` is still a preview rule, so `preview` has to be on for it. Pair it with
# `explicit-preview-rules` so only the preview rules named in `select` below turn on,
# instead of every preview rule of the selected families.
preview = true
explicit-preview-rules = true
select = [
"E", # pycodestyle errors
"F", # Pyflakes
"I", # isort
"W", # pycodestyle warnings
"UP", # pyupgrade
"FURB", # refurb
"SIM", # flake8-simplify
"S110", # bandit's try-except-pass rule
"C4", # flake8-comprehensions
"C901", # McCabe complexity
"RUF013", # Checks for the use of implicit Optional in type annotations when the default parameter value is None.
"PERF102", # Checks for uses of dict.items() that discard either the key or the value when iterating over the dictionary.
"PLC1802", # Checks for len calls on sequences in a boolean test context.
"PLC0208", # Checks for iteration over a set literal where each element in the set is itself a literal value.
"PIE794", # Checks for duplicate field definitions in classes.
"PLW1514", # Checks that `open()` in text mode is called with an explicit encoding.
]
ignore = [
"E501", # Checks for lines that exceed the specified maximum character length.
"E741", # Checks for the use of the characters 'l', 'O', or 'I' as variable names.
"SIM1", # All SIM1XX rules
"SIM905", # Checks for static str.split calls that can be replaced with list literals.
"UP015", # Checks for redundant open mode arguments.
"UP031", # Checks for printf-style string formatting, and offers to replace it with str.format calls.
]
extend-safe-fixes = [
"UP006", # Checks for the use of generics that can be replaced with standard library variants based on PEP 585.
]
# Codes owned by other checkers, so ruff keeps `# noqa: <code>` for them instead of warning it is invalid.
external = [
"NC", # utils/check_noisy_comments.py
]
# Ignore import violations in all `__init__.py` files.
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403", "F811"]
"examples/**/*.py" = ["C901"]
"src/transformers/file_utils.py" = ["F401"]
"src/transformers/utils/dummy_*.py" = ["F401"]
[tool.ruff.lint.isort]
lines-after-imports = 2
known-first-party = ["transformers"]
[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[tool.ruff.lint.mccabe]
max-complexity = 75
[tool.pytest.ini_options]
addopts = "--doctest-glob='**/*.md'"
doctest_optionflags="NUMBER NORMALIZE_WHITESPACE ELLIPSIS"
markers = [
"all_flash_attn_test: marks tests related to all mainline flash attentions at once (deselect with '-m \"not all_flash_attn_test\"')",
"flash_attn_4_test: marks tests related to flash attention 4 (deselect with '-m \"not flash_attn_4_test\"')",
"flash_attn_3_test: marks tests related to flash attention 3 (deselect with '-m \"not flash_attn_3_test\"')",
"flash_attn_test: marks tests related to flash attention (deselect with '-m \"not flash_attn_test\"')",
"bitsandbytes: select (or deselect with `not`) bitsandbytes integration tests",
"generate: marks tests that use the GenerationTesterMixin",
"is_training_test: marks tests that use the TrainingTesterMixin (deselect with '-m \"not is_training_test\"')",
"is_tensor_parallel_test: marks tests that use the TensorParallelTesterMixin (deselect with '-m \"not is_tensor_parallel_test\"')",
"is_fsdp_test: marks tests that use the FSDPTesterMixin (deselect with '-m \"not is_fsdp_test\"')",
]
log_cli = 1
log_cli_level = "WARNING"
asyncio_default_fixture_loop_scope = "function"
filterwarnings = [
# The above pytest-asyncio rule emits unnessecary warnings when it's not installed, so skip it here
"ignore:Unknown config option.*asyncio_default_fixture_loop_scope",
# Latest sentencepiece (v0.2.1) triggers those warnings when installed due to its build with afflicted version of swig - skip them
"ignore:builtin type SwigPyPacked has no __module__ attribute:DeprecationWarning",
"ignore:builtin type SwigPyObject has no __module__ attribute:DeprecationWarning",
"ignore:builtin type swigvarlink has no __module__ attribute:DeprecationWarning",
]
env = [
# Avoid any ReadTimeout when making requests to the Hub (default is 10)
# Note: 'D:' means default value from laptop or CI won't be overwritten
"D:HF_HUB_DOWNLOAD_TIMEOUT=60",
]
[tool.ty]
# ty type checker configuration
# Using default settings for comprehensive type checking
[tool.ty.rules]
# Disable specific rules that produce false positives or are too strict for this codebase
invalid-method-override = "ignore" # Parameter name differences are acceptable (e.g., x vs input, new_embeddings vs value)
not-subscriptable = "ignore" # False positives on tensor slicing (e.g., self.position_ids[:, :seq_length])
no-matching-overload = "ignore" # False positives on torch.zeros and similar functions accepting Size/tuple
unsupported-operator = "ignore" # False positives on tuple concatenation with += when properly initialized
unresolved-import = "ignore" # Optional dependencies (mlx, torch_npu, habana_frameworks, etc.) checked at runtime
call-non-callable = "ignore" # Mixin pattern issues where classes are used as both types and callables
unresolved-reference = "ignore" # Forward references with noqa: F821 that ty doesn't respect
invalid-argument-type = "ignore" # Complex type narrowing and union type issues
not-iterable = "ignore" # Complex async/Future type patterns
invalid-return-type = "ignore" # Return type mismatches that would require refactoring
deprecated = "ignore" # Deprecation warnings from dependencies
invalid-assignment = "ignore" # Low-level assignments that are runtime-safe
unused-ignore-comment = "ignore" # Ignore comments that became unnecessary after adding broader per-file-ignores
unused-type-ignore-comment = "ignore" # A `# type: ignore` counts as "used" only when its suppressed error fires, which needs optional deps (torch, openai, ...) installed. CI's lean `quality` env lacks them, so directives used locally look unused in CI.