Skip to content

Commit 3279b1d

Browse files
authored
ci: Upgrade ruff to 0.0.253 and enable more rules (#2983)
1 parent d23408d commit 3279b1d

File tree

18 files changed

+47
-47
lines changed

18 files changed

+47
-47
lines changed

bin/parse_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
def parse(s: str) -> Iterator[Tuple[str, str]]:
2121
"""Parse an AWS docs page in Markdown format, yielding each property."""
2222
# Prevent from parsing return values accidentally
23-
s = stringbetween(s, "#\s+Properties", "#\s+Return values")
23+
s = stringbetween(s, "#\\s+Properties", "#\\s+Return values")
2424
if not s:
2525
return
2626
parts = s.split("\n\n")
@@ -44,7 +44,7 @@ def remove_first_line(s: str) -> str:
4444

4545

4646
def convert_to_full_path(description: str, prefix: str) -> str:
47-
pattern = re.compile("\(([#\.a-zA-Z0-9_-]+)\)")
47+
pattern = re.compile("\\(([#\\.a-zA-Z0-9_-]+)\\)")
4848
matched_content = pattern.findall(description)
4949

5050
for path in matched_content:

bin/public_interface.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ def _only_new_optional_arguments_or_existing_arguments_optionalized_or_var_argum
161161
return False
162162
# it is an optional argument when it has a default value:
163163
return all(
164-
[
165-
"default" in argument or argument["kind"] in ("VAR_KEYWORD", "VAR_POSITIONAL")
166-
for argument in arguments[len(original_arguments) :]
167-
]
164+
"default" in argument or argument["kind"] in ("VAR_KEYWORD", "VAR_POSITIONAL")
165+
for argument in arguments[len(original_arguments) :]
168166
)
169167

170168

requirements/dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pytest-xdist>=2.5,<4
44
pytest-env>=0.6,<1
55
pytest-rerunfailures>=9.1,<12
66
pyyaml~=6.0
7-
ruff==0.0.252 # loose the requirement once it is more stable
7+
ruff==0.0.253 # loose the requirement once it is more stable
88

99
# Test requirements
1010
pytest>=6.2,<8

ruff.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
line-length = 999
33

44
select = [
5-
"E", # Pyflakes
5+
"E", # pycodestyle
6+
"W", # pycodestyle
67
"F", # Pyflakes
78
"PL", # pylint
89
"I", # isort
@@ -17,6 +18,7 @@ select = [
1718
"SIM", # flake8-simplify
1819
"TID", # flake8-tidy-imports
1920
"RUF", # Ruff-specific rules
21+
"YTT", # flake8-2020
2022
]
2123

2224
# Mininal python version we support is 3.7

samtranslator/feature_toggle/dialup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class BaseDialup(ABC):
66
"""BaseDialup class to provide an interface for all dialup classes"""
77

8-
def __init__(self, region_config, **kwargs): # type: ignore[no-untyped-def]
8+
def __init__(self, region_config, **kwargs) -> None: # type: ignore[no-untyped-def]
99
self.region_config = region_config
1010

1111
@abstractmethod
@@ -23,8 +23,8 @@ class DisabledDialup(BaseDialup):
2323
A dialup that is never enabled
2424
"""
2525

26-
def __init__(self, region_config, **kwargs): # type: ignore[no-untyped-def]
27-
super().__init__(region_config) # type: ignore[no-untyped-call]
26+
def __init__(self, region_config, **kwargs) -> None: # type: ignore[no-untyped-def]
27+
super().__init__(region_config)
2828

2929
def is_enabled(self) -> bool:
3030
return False
@@ -36,8 +36,8 @@ class ToggleDialup(BaseDialup):
3636
Example of region_config: { "type": "toggle", "enabled": True }
3737
"""
3838

39-
def __init__(self, region_config, **kwargs): # type: ignore[no-untyped-def]
40-
super().__init__(region_config) # type: ignore[no-untyped-call]
39+
def __init__(self, region_config, **kwargs) -> None: # type: ignore[no-untyped-def]
40+
super().__init__(region_config)
4141
self.region_config = region_config
4242

4343
def is_enabled(self): # type: ignore[no-untyped-def]
@@ -50,8 +50,8 @@ class SimpleAccountPercentileDialup(BaseDialup):
5050
Example of region_config: { "type": "account-percentile", "enabled-%": 20 }
5151
"""
5252

53-
def __init__(self, region_config, account_id, feature_name, **kwargs): # type: ignore[no-untyped-def]
54-
super().__init__(region_config) # type: ignore[no-untyped-call]
53+
def __init__(self, region_config, account_id, feature_name, **kwargs) -> None: # type: ignore[no-untyped-def]
54+
super().__init__(region_config)
5555
self.account_id = account_id
5656
self.feature_name = feature_name
5757

samtranslator/feature_toggle/feature_toggle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _get_dialup(self, region_config, feature_name): # type: ignore[no-untyped-d
5656
region_config, account_id=self.account_id, feature_name=feature_name
5757
)
5858
LOG.warning("Dialup type '{}' is None or is not supported.".format(dialup_type))
59-
return DisabledDialup(region_config) # type: ignore[no-untyped-call]
59+
return DisabledDialup(region_config)
6060

6161
def is_enabled(self, feature_name: str) -> bool:
6262
"""
@@ -119,7 +119,7 @@ def config(self) -> Dict[str, Any]:
119119
class FeatureToggleLocalConfigProvider(FeatureToggleConfigProvider):
120120
"""Feature toggle config provider which uses a local file. This is to facilitate local testing."""
121121

122-
def __init__(self, local_config_path): # type: ignore[no-untyped-def]
122+
def __init__(self, local_config_path) -> None: # type: ignore[no-untyped-def]
123123
FeatureToggleConfigProvider.__init__(self)
124124
with open(local_config_path, "r", encoding="utf-8") as f:
125125
config_json = f.read()
@@ -134,7 +134,7 @@ class FeatureToggleAppConfigConfigProvider(FeatureToggleConfigProvider):
134134
"""Feature toggle config provider which loads config from AppConfig."""
135135

136136
@cw_timer(prefix="External", name="AppConfig")
137-
def __init__(self, application_id, environment_id, configuration_profile_id, app_config_client=None): # type: ignore[no-untyped-def]
137+
def __init__(self, application_id, environment_id, configuration_profile_id, app_config_client=None) -> None: # type: ignore[no-untyped-def]
138138
FeatureToggleConfigProvider.__init__(self)
139139
try:
140140
LOG.info("Loading feature toggle config from AppConfig...")

samtranslator/metrics/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def publish(self, namespace: str, metrics: List["MetricDatum"]) -> None:
2525
class CWMetricsPublisher(MetricsPublisher):
2626
BATCH_SIZE = 20
2727

28-
def __init__(self, cloudwatch_client): # type: ignore[no-untyped-def]
28+
def __init__(self, cloudwatch_client) -> None: # type: ignore[no-untyped-def]
2929
"""
3030
Constructor
3131
@@ -90,7 +90,7 @@ class MetricDatum:
9090
Class to hold Metric data.
9191
"""
9292

93-
def __init__(self, name, value, unit, dimensions=None, timestamp=None): # type: ignore[no-untyped-def]
93+
def __init__(self, name, value, unit, dimensions=None, timestamp=None) -> None: # type: ignore[no-untyped-def]
9494
"""
9595
Constructor
9696
@@ -148,7 +148,7 @@ def _record_metric(self, name, value, unit, dimensions=None, timestamp=None): #
148148
:param dimensions: array of dimensions applied to the metric
149149
:param timestamp: timestamp of metric (datetime.datetime object)
150150
"""
151-
self.metrics_cache.setdefault(name, []).append(MetricDatum(name, value, unit, dimensions, timestamp)) # type: ignore[no-untyped-call]
151+
self.metrics_cache.setdefault(name, []).append(MetricDatum(name, value, unit, dimensions, timestamp))
152152

153153
def record_count(self, name, value, dimensions=None, timestamp=None): # type: ignore[no-untyped-def]
154154
"""

samtranslator/model/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ class ResourceTypeResolver:
548548
"""ResourceTypeResolver maps Resource Types to Resource classes, e.g. AWS::Serverless::Function to
549549
samtranslator.model.sam_resources.SamFunction."""
550550

551-
def __init__(self, *modules: Any):
551+
def __init__(self, *modules: Any) -> None:
552552
"""Initializes the ResourceTypeResolver from the given modules.
553553
554554
:param modules: one or more Python modules containing Resource definitions
@@ -589,7 +589,7 @@ def resolve_resource_type(self, resource_dict: Dict[str, Any]) -> Any:
589589

590590

591591
class ResourceResolver:
592-
def __init__(self, resources: Dict[str, Any]):
592+
def __init__(self, resources: Dict[str, Any]) -> None:
593593
"""
594594
Instantiate the resolver
595595
:param dict resources: Map of resource

samtranslator/model/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class InvalidDocumentException(ExceptionWithMessage):
3232
causes -- list of errors which caused this document to be invalid
3333
"""
3434

35-
def __init__(self, causes: Sequence[ExceptionWithMessage]):
35+
def __init__(self, causes: Sequence[ExceptionWithMessage]) -> None:
3636
self._causes = list(causes)
3737
# Sometimes, the same error could be raised from different plugins,
3838
# so here we do a deduplicate based on the message:

samtranslator/model/resource_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ResourcePolicies:
2929

3030
POLICIES_PROPERTY_NAME = "Policies"
3131

32-
def __init__(self, resource_properties: Dict[str, Any], policy_template_processor: Any = None):
32+
def __init__(self, resource_properties: Dict[str, Any], policy_template_processor: Any = None) -> None:
3333
"""
3434
Initialize with policies data from resource's properties
3535

0 commit comments

Comments
 (0)