1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15# Exclude a variety of commonly ignored directories. 16exclude = [ 17 'out', 18 '.environment', 19 'environment', 20 '.mypy_cache', 21 '.pytype', 22 '.ruff_cache', 23 '__pycache__', 24 '__pypackages__', 25] 26 27respect-gitignore = true 28 29line-length = 80 30 31# Assume Python 3.10. 32target-version = 'py310' 33 34[lint] 35# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default. 36# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or 37# McCabe complexity (`C901`) by default. 38select = [ 39 'F', # Pyflakes 40 'E', # pycodestyle 41 'C90', # mccabe 42 'I', # isort 43 'N', # pep8-naming 44 'D', # pydocstyle 45 'UP', # pyupgrade 46 'YTT', # flake8-2020 47 'ANN', # flake8-annotations 48 'ASYNC', # flake8-async 49 'S', # flake8-bandit 50 'BLE', # flake8-blind-except 51 'FBT', # flake8-boolean-trap 52 'B', # flake8-bugbear 53 'A', # flake8-builtins 54 'COM', # flake8-commas 55 'C4', # flake8-comprehensions 56 'DTZ', # flake8-datetimez 57 'T10', # flake8-debugger 58 'DJ', # flake8-django 59 'EM', # flake8-errmsg 60 'EXE', # flake8-executable 61 'FA', # flake8-future-annotations 62 'ISC', # flake8-implicit-str-concat 63 'ICN', # flake8-import-conventions 64 'G', # flake8-logging-format 65 'INP', # flake8-no-pep420 66 'PIE', # flake8-pie 67 'T20', # flake8-print 68 'PYI', # flake8-pyi 69 'PT', # flake8-pytest-style 70 # 'Q', # flake8-quotes 71 'RSE', # flake8-raise 72 'RET', # flake8-return 73 'SLF', # flake8-self 74 'SLOT', # flake8-slots 75 'SIM', # flake8-simplify 76 'TID', # flake8-tidy-imports 77 'TCH', # flake8-type-checking 78 'INT', # flake8-gettext 79 'ARG', # flake8-unused-arguments 80 'PTH', # flake8-use-pathlib 81 'TD', # flake8-todos 82 'FIX', # flake8-fixme 83 'ERA', # eradicate 84 'PD', # pandas-vet 85 'PGH', # pygrep-hooks 86 'PL', # Pylint 87 'TRY', # tryceratops 88 'FLY', # flynt 89 'NPY', # NumPy-specific rules 90 'AIR', # Airflow 91 'PERF', # Perflint 92 'RUF', # Ruff-specific rules 93] 94 95# All Rule codes: https://docs.astral.sh/ruff/rules/ 96ignore = [ 97 'ANN101', # https://docs.astral.sh/ruff/rules/missing-type-self 98 'COM812', # Trailing comma missing 99 'D203', # https://docs.astral.sh/ruff/rules/one-blank-line-before-class 100 'D212', # https://docs.astral.sh/ruff/rules/multi-line-summary-first-line 101 'D213', # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line 102 'D400', # First line should end with a period 103 'D401', # First line of docstring should be in imperative mood 104 'D404', # First word of the docstring should not be "This"' 105 'D415', # First line should end with a period, question mark, or exclamation point 106 'D416', # Section name should end with a colon ("Raises")' 107 'FIX002', # Line contains TODO, consider resolving the issue 108 'PGH003', # Use specific rule codes when ignoring type issues 109 'PT009', # Use a regular `assert` instead of unittest-style `assertEqual` 110 'PTH123', # `open()` should be replaced by `Path.open()` 111 'S101', # Use of `assert` detected 112 'TD003', # Missing issue link on the line following this TODO 113 'UP006', # Use `list` instead of `List` for type annotation 114] 115 116# Allow autofix for all enabled rules (when `--fix`) is provided. 117fixable = ['ALL'] 118unfixable = [] 119 120# Allow unused variables when underscore-prefixed. 121dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$' # inclusive-language: ignore 122 123[lint.per-file-ignores] 124# pw_python_package tests often live outside any top level module. 125'**/py/*_test.py' = [ 126 'INP001', # File is part of an implicit namespace package. Add an `__init__.py`. 127] 128 129[lint.pycodestyle] 130ignore-overlong-task-comments = true 131# Same as .black.toml 132max-doc-length = 88 133