File size: 4,156 Bytes
4021124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Enable rules.
lint.select = [
    "A",   # flake8-builtins - https://beta.ruff.rs/docs/rules/#flake8-builtins-a
    "B",   # flake8-bugbear-b - https://beta.ruff.rs/docs/rules/#flake8-bugbear-b
    "C4",  # flake8-comprehensions - https://beta.ruff.rs/docs/rules/#flake8-comprehensions-c4
    "C90", # mccabe - https://beta.ruff.rs/docs/rules/#mccabe-c90
    "COM", # flak8-commas - https://beta.ruff.rs/docs/rules/#flake8-commas-com
    #"D", # pydocstyle - not enabled temporarily
    "E",   # pycodestyle error - https://beta.ruff.rs/docs/rules/#error-e
    "ERA", # flake8-eradicate - https://beta.ruff.rs/docs/rules/#eradicate-era
    "FA",  # flake8-future-annotations - https://beta.ruff.rs/docs/rules/#flake8-future-annotations-fa
    "FIX", # flake8-fixme - https://beta.ruff.rs/docs/rules/#flake8-fixme-fix
    "F",   # pyflakes - https://beta.ruff.rs/docs/rules/#pyflakes-f
    "I",   # isort - https://beta.ruff.rs/docs/rules/#isort-i
    "ICN", # flake8-import-conventions - https://beta.ruff.rs/docs/rules/#flake8-import-conventions-icn
    "ISC", # flake8-implicit-str-concat - https://beta.ruff.rs/docs/rules/#flake8-implicit-str-concat-isc
    "PLE", # pylint error - https://beta.ruff.rs/docs/rules/#error-ple
    "PLC", # pylint convention - https://beta.ruff.rs/docs/rules/#convention-plc
    "PLR", # pylint refactoring - https://beta.ruff.rs/docs/rules/#refactor-plr
    "PLW", # pylint warning - https://beta.ruff.rs/docs/rules/#warning-plw
    "PL",  # pylint - https://beta.ruff.rs/docs/rules/#pylint-pl
    "PYI", # flake8-pyi - https://beta.ruff.rs/docs/rules/#flake8-pyi-pyi
    "Q",   # flake8-quotes - https://beta.ruff.rs/docs/rules/#flake8-quotes-q
    "PTH", # flake8-use-pathlib - https://beta.ruff.rs/docs/rules/#flake8-use-pathlib-pth
    "T10", # flake8-debugger https://beta.ruff.rs/docs/rules/#flake8-debugger-t10
    "TCH", # flake8-type-checking - https://docs.astral.sh/ruff/rules/#flake8-type-checking-tch
    "TD",  # flake8-todo - https://beta.ruff.rs/docs/rules/#flake8-todos-td
    "UP",  # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
    "W",   # pycodestyle warning - https://beta.ruff.rs/docs/rules/#warning-w
]

# Ignore specific rules
lint.ignore = [
    "W291",    # https://beta.ruff.rs/docs/rules/trailing-whitespace/
    "PLR0913", # https://beta.ruff.rs/docs/rules/too-many-arguments/
    "PLR2004", #https://beta.ruff.rs/docs/rules/magic-value-comparison/
    "PLW0603", #https://beta.ruff.rs/docs/rules/global-statement/
    "B904",    # raise-without-from-inside-except - disabled temporarily
    "PLC1901", # Compare-to-empty-string - disabled temporarily
    "PYI024",
]

# Exclude files and directories
exclude = [
    "docs",
    ".eggs",
    "setup.py",
    "example",
    ".aws-sam",
    ".git",
    "dist",
    ".md",
    ".yaml",
    "example/samconfig.toml",
    ".txt",
    ".ini",
]

# Maximum line length
line-length = 120

target-version = "py38"

fix = true
lint.fixable = ["I", "COM812", "W"]

# See: https://github.com/astral-sh/ruff/issues/128
lint.typing-modules = [
    "aws_lambda_powertools.utilities.parser.types",
    "aws_lambda_powertools.shared.types",
]

[lint.mccabe]
# Maximum cyclomatic complexity
max-complexity = 15

[lint.pylint]
# Maximum number of nested blocks
max-branches = 15
# Maximum number of if statements in a function
max-statements = 70

[lint.isort]
split-on-trailing-comma = true

[lint.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel"]

[lint.per-file-ignores]
# Ignore specific rules for specific files
"tests/e2e/utils/data_builder/__init__.py" = ["F401"]
"tests/e2e/utils/data_fetcher/__init__.py" = ["F401"]
"aws_lambda_powertools/utilities/data_classes/s3_event.py" = ["A003"]
"aws_lambda_powertools/utilities/parser/models/__init__.py" = ["E402"]
"aws_lambda_powertools/event_handler/openapi/compat.py" = ["F401"]
# Maintenance: we're keeping EphemeralMetrics code in case of Hyrum's law so we can quickly revert it
"aws_lambda_powertools/metrics/metrics.py" = ["ERA001"]
"examples/*" = ["FA100", "TCH"]
"tests/*" = ["FA100", "TCH"]
"aws_lambda_powertools/utilities/parser/models/*" = ["FA100"]