Skip to content

Commit 116ab59

Browse files
committed
Remove contextlib.suppress usages
1 parent e552538 commit 116ab59

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

pyproject.toml

+20-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ select = [
6767
"RSE", # flake8-raise
6868
"RUF", # Ruff-specific and unused-noqa
6969
"S", # flake8-bandit
70-
"SIM", # flake8-simplify
7170
"SLOT", # flake8-slots
7271
"TRY", # tryceratops
7372
"UP", # pyupgrade
@@ -78,11 +77,6 @@ select = [
7877
"W", # pycodestyle Warning
7978
# Only include flake8-annotations rules that are autofixable. Otherwise leave this to mypy+pyright
8079
"ANN2",
81-
# Don't include TC rules that create a TYPE_CHECKING block or stringifies annotations
82-
"TC004", # Move import `{qualified_name}` out of type-checking block. Import is used for more than type hinting.
83-
"TC005", # Found empty type-checking block
84-
# "TC008", # TODO: Enable when out of preview
85-
"TC010", # Invalid string member in `X | Y`-style union type
8680
# Most refurb rules are in preview and can be opinionated,
8781
# consider them individually as they come out of preview (last check: 0.8.4)
8882
"FURB105", # Unnecessary empty string passed to `print`
@@ -117,6 +111,26 @@ select = [
117111
# "PYI061", # TODO: Enable when out of preview
118112
"PYI062", # Duplicate literal member `{}`
119113
"PYI064", # `Final[Literal[{literal}]]` can be replaced with a bare Final
114+
# flake8-simplify, excluding rules that can reduce performance or readability due to long line formatting
115+
"SIM101", # Multiple `isinstance` calls for `{name}`, merge into a single call
116+
"SIM103", # Return the condition `{condition}` directly
117+
"SIM107", # Don't use return in `try-except` and `finally`
118+
"SIM109", # Use `{replacement}` instead of multiple equality comparisons
119+
"SIM112", # Use capitalized environment variable `{expected}` instead of `{actual}`
120+
"SIM113", # Use `enumerate()` for index variable `{index}` in `for` loop
121+
"SIM114", # Combine `if` branches using logical `or` operator
122+
"SIM115", # Use a context manager for opening files
123+
"SIM118", # Use key `{operator}` dict instead of key `{operator} dict.keys()`
124+
"SIM2", # flake8-simplify conditional ordering rules
125+
"SIM300", # Yoda condition detected
126+
"SIM401", # Use `{contents}` instead of an if block
127+
"SIM910", # Use `{expected}` instead of `{actual}` (dict-get-with-none-default)
128+
"SIM911", # Use `{expected}` instead of `{actual}` (zip-dict-keys-and-values)
129+
# Don't include TC rules that create a TYPE_CHECKING block or stringifies annotations
130+
"TC004", # Move import `{qualified_name}` out of type-checking block. Import is used for more than type hinting.
131+
"TC005", # Found empty type-checking block
132+
# "TC008", # TODO: Enable when out of preview
133+
"TC010", # Invalid string member in `X | Y`-style union type
120134
]
121135
extend-safe-fixes = [
122136
"UP036", # Remove unnecessary `sys.version_info` blocks

scripts/stubsabot.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import argparse
55
import asyncio
6-
import contextlib
76
import datetime
87
import enum
98
import functools
@@ -334,8 +333,10 @@ async def get_diff_info(
334333
# Some packages in typeshed have tag names
335334
# that are invalid to be passed to the Version() constructor,
336335
# e.g. v.1.4.2
337-
with contextlib.suppress(packaging.version.InvalidVersion):
336+
try:
338337
versions_to_tags[packaging.version.Version(tag_name)] = tag_name
338+
except packaging.version.InvalidVersion:
339+
pass
339340

340341
try:
341342
new_tag = versions_to_tags[pypi_version]

tests/stubtest_third_party.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from __future__ import annotations
55

66
import argparse
7-
import contextlib
87
import os
98
import re
109
import subprocess
@@ -406,5 +405,7 @@ def main() -> NoReturn:
406405

407406

408407
if __name__ == "__main__":
409-
with contextlib.suppress(KeyboardInterrupt):
408+
try:
410409
main()
410+
except KeyboardInterrupt:
411+
pass

0 commit comments

Comments
 (0)