| [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] | |
| 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 | |
| "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. | |
| ] | |
| 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. | |
| ] | |
| # Ignore import violations in all `__init__.py` files. | |
| [tool.ruff.lint.per-file-ignores] | |
| "__init__.py" = ["E402", "F401", "F403", "F811"] | |
| "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.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\"')", | |
| ] | |
| 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 | |