1[build-system] 2requires = [ 3 "setuptools", 4 "wheel", 5 "astunparse", 6 "numpy", 7 "ninja", 8 "pyyaml", 9 "cmake", 10 "typing-extensions", 11 "requests", 12] 13# Use legacy backend to import local packages in setup.py 14build-backend = "setuptools.build_meta:__legacy__" 15 16 17[tool.black] 18line-length = 88 19target-version = ["py38"] 20 21 22[tool.isort] 23src_paths = ["caffe2", "torch", "torchgen", "functorch", "test"] 24extra_standard_library = ["typing_extensions"] 25skip_gitignore = true 26skip_glob = ["third_party/*"] 27atomic = true 28profile = "black" 29indent = 4 30line_length = 88 31lines_after_imports = 2 32multi_line_output = 3 33include_trailing_comma = true 34combine_as_imports = true 35 36 37[tool.usort.known] 38first_party = ["caffe2", "torch", "torchgen", "functorch", "test"] 39standard_library = ["typing_extensions"] 40 41 42[tool.ruff] 43target-version = "py38" 44line-length = 88 45src = ["caffe2", "torch", "torchgen", "functorch", "test"] 46 47[tool.ruff.format] 48docstring-code-format = true 49quote-style = "double" 50 51[tool.ruff.lint] 52# NOTE: Synchoronize the ignores with .flake8 53ignore = [ 54 # these ignores are from flake8-bugbear; please fix! 55 "B007", "B008", "B017", 56 "B018", # Useless expression 57 "B023", 58 "B028", # No explicit `stacklevel` keyword argument found 59 "E402", 60 "C408", # C408 ignored because we like the dict keyword argument syntax 61 "E501", # E501 is not flexible enough, we're using B950 instead 62 "E721", 63 "E731", # Assign lambda expression 64 "E741", 65 "EXE001", 66 "F405", 67 "F841", 68 # these ignores are from flake8-logging-format; please fix! 69 "G101", 70 # these ignores are from ruff NPY; please fix! 71 "NPY002", 72 # these ignores are from ruff PERF; please fix! 73 "PERF203", 74 "PERF401", 75 "PERF403", 76 # these ignores are from PYI; please fix! 77 "PYI024", 78 "PYI036", 79 "PYI041", 80 "PYI056", 81 "SIM102", "SIM103", "SIM112", # flake8-simplify code styles 82 "SIM113", # please fix 83 "SIM105", # these ignores are from flake8-simplify. please fix or ignore with commented reason 84 "SIM108", # SIM108 ignored because we prefer if-else-block instead of ternary expression 85 "SIM110", 86 "SIM114", # Combine `if` branches using logical `or` operator 87 "SIM115", 88 "SIM116", # Disable Use a dictionary instead of consecutive `if` statements 89 "SIM117", 90 "SIM118", 91 "UP006", # keep-runtime-typing 92 "UP007", # keep-runtime-typing 93] 94select = [ 95 "B", 96 "B904", # Re-raised error without specifying the cause via the from keyword 97 "C4", 98 "G", 99 "E", 100 "EXE", 101 "F", 102 "SIM1", 103 "SIM911", 104 "W", 105 # Not included in flake8 106 "FURB", 107 "LOG", 108 "NPY", 109 "PERF", 110 "PGH004", 111 "PIE790", 112 "PIE794", 113 "PIE800", 114 "PIE804", 115 "PIE807", 116 "PIE810", 117 "PLC0131", # type bivariance 118 "PLC0132", # type param mismatch 119 "PLC0205", # string as __slots__ 120 "PLC3002", # unnecessary-direct-lambda-call 121 "PLE", 122 "PLR0133", # constant comparison 123 "PLR0206", # property with params 124 "PLR1722", # use sys exit 125 "PLR1736", # unnecessary list index 126 "PLW0129", # assert on string literal 127 "PLW0133", # useless exception statement 128 "PLW0406", # import self 129 "PLW0711", # binary op exception 130 "PLW1509", # preexec_fn not safe with threads 131 "PLW2101", # useless lock statement 132 "PLW3301", # nested min max 133 "PT006", # TODO: enable more PT rules 134 "PT022", 135 "PT023", 136 "PT024", 137 "PT025", 138 "PT026", 139 "PYI", 140 "Q003", # avoidable escaped quote 141 "Q004", # unnecessary escaped quote 142 "RSE", 143 "RUF008", # mutable dataclass default 144 "RUF015", # access first ele in constant time 145 "RUF016", # type error non-integer index 146 "RUF017", 147 "RUF018", # no assignment in assert 148 "RUF019", # unnecessary-key-check 149 "RUF024", # from keys mutable 150 "RUF026", # default factory kwarg 151 "TCH", 152 "TRY002", # ban vanilla raise (todo fix NOQAs) 153 "TRY302", 154 "TRY401", # verbose-log-message 155 "UP", 156] 157 158[tool.ruff.lint.per-file-ignores] 159"__init__.py" = [ 160 "F401", 161] 162"functorch/notebooks/**" = [ 163 "F401", 164] 165"test/typing/reveal/**" = [ 166 "F821", 167] 168"test/torch_np/numpy_tests/**" = [ 169 "F821", 170 "NPY201", 171] 172"test/dynamo/test_bytecode_utils.py" = [ 173 "F821", 174] 175"test/dynamo/test_debug_utils.py" = [ 176 "UP037", 177] 178"test/jit/**" = [ 179 "PLR0133", # tests require this for JIT 180 "PYI", 181 "RUF015", 182 "UP", # We don't want to modify the jit test as they test specify syntax 183] 184"test/test_jit.py" = [ 185 "PLR0133", # tests require this for JIT 186 "PYI", 187 "RUF015", 188 "UP", # We don't want to modify the jit test as they test specify syntax 189] 190"test/inductor/test_torchinductor.py" = [ 191 "UP037", 192] 193# autogenerated #TODO figure out why file level noqa is ignored 194"torch/_inductor/fx_passes/serialized_patterns/**" = ["F401", "F501"] 195"torch/_inductor/autoheuristic/artifacts/**" = ["F401", "F501"] 196"torchgen/api/types/__init__.py" = [ 197 "F401", 198 "F403", 199] 200"torchgen/executorch/api/types/__init__.py" = [ 201 "F401", 202 "F403", 203] 204"torch/utils/collect_env.py" = [ 205 "UP", # collect_env.py needs to work with older versions of Python 206] 207"torch/_vendor/**" = [ 208 "UP", # No need to mess with _vendor 209] 210