From 2d26de49bd751947f554b2c33fe6ac5f2873687c Mon Sep 17 00:00:00 2001 From: Sam Liu Date: Thu, 23 Feb 2023 14:59:06 -0800 Subject: [PATCH] chore: Batch update dev dependencies --- bin/parse_docs.py | 4 +-- requirements/dev.txt | 25 +++++++++---------- samtranslator/model/api/api_generator.py | 3 +-- samtranslator/model/api/http_api_generator.py | 6 ++--- samtranslator/open_api/open_api.py | 3 +-- samtranslator/third_party/py27hash/hash.py | 3 +-- samtranslator/translator/translator.py | 7 +++--- samtranslator/utils/py27hash_fix.py | 5 ++-- 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/bin/parse_docs.py b/bin/parse_docs.py index 8621f534d..80c9dfabc 100755 --- a/bin/parse_docs.py +++ b/bin/parse_docs.py @@ -89,10 +89,10 @@ def main() -> None: if args.cfn and not re.match(r"^\w+::\w+::\w+( \w+)?$", title): continue page = title if args.cfn else path.stem - for name, description in parse(text): + for name, raw_description in parse(text): if page not in props: props[page] = {} - description = remove_first_line(description) # Remove property name; already in the schema title + description = remove_first_line(raw_description) # Remove property name; already in the schema title description = fix_markdown_code_link(description) prefix = ( "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/" diff --git a/requirements/dev.txt b/requirements/dev.txt index e652d392e..9555b9cf1 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,22 +1,21 @@ -coverage~=5.3 -pytest-cov~=2.10.1 -pytest-xdist~=2.5 -pytest-env~=0.6.2 -pytest-rerunfailures~=9.1.1 -pyyaml~=5.4 -ruff==0.0.244 # loose the requirement once it is more stable +coverage~=7.2 +pytest-cov~=4.0 +pytest-xdist~=3.2 +pytest-env~=0.8.1 +pytest-rerunfailures~=11.1 +pyyaml~=6.0 +ruff==0.0.252 # loose the requirement once it is more stable # Test requirements -pytest~=6.2.5 -parameterized~=0.7.4 +pytest~=7.2 +parameterized~=0.8.1 # Integration tests -dateparser~=0.7 +dateparser~=1.1 boto3>=1.23,<2 -tenacity~=7.0.0 # Requirements for examples -requests~=2.25.0 +requests~=2.28 # formatter black==23.1.0 @@ -27,5 +26,5 @@ mypy~=1.0.0 # types boto3-stubs[appconfig,serverlessrepo]>=1.19.5,==1.* -types-PyYAML~=5.4 +types-PyYAML~=6.0 types-jsonschema~=3.2 diff --git a/samtranslator/model/api/api_generator.py b/samtranslator/model/api/api_generator.py index c1c39e59b..5802b1efc 100644 --- a/samtranslator/model/api/api_generator.py +++ b/samtranslator/model/api/api_generator.py @@ -521,7 +521,6 @@ def _construct_api_domain( # noqa: too-many-branches # Remove possible leading and trailing '/' because a base path may only # contain letters, numbers, and one of "$-_.+!*'()" path = "".join(e for e in basepath if e.isalnum()) - basepath = path if normalize_basepath else basepath logical_id = "{}{}{}".format(self.logical_id, path, "BasePathMapping") basepath_mapping = ApiGatewayBasePathMapping( logical_id, attributes=self.passthrough_resource_attributes @@ -529,7 +528,7 @@ def _construct_api_domain( # noqa: too-many-branches basepath_mapping.DomainName = ref(api_domain_name) basepath_mapping.RestApiId = ref(rest_api.logical_id) basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage") - basepath_mapping.BasePath = basepath + basepath_mapping.BasePath = path if normalize_basepath else basepath basepath_resource_list.extend([basepath_mapping]) # Create the Route53 RecordSetGroup resource diff --git a/samtranslator/model/api/http_api_generator.py b/samtranslator/model/api/http_api_generator.py index 2e2e6a045..9a6a87824 100644 --- a/samtranslator/model/api/http_api_generator.py +++ b/samtranslator/model/api/http_api_generator.py @@ -401,15 +401,13 @@ def _construct_basepath_mappings( if re.search(invalid_regex, path) is not None: raise InvalidResourceException(self.logical_id, "Invalid Basepath name provided.") - # ignore leading and trailing `/` in the path name - path = path.strip("/") - logical_id = "{}{}{}".format(self.logical_id, re.sub(r"[\-_/]+", "", path), "ApiMapping") basepath_mapping = ApiGatewayV2ApiMapping(logical_id, attributes=self.passthrough_resource_attributes) basepath_mapping.DomainName = ref(api_domain_name) basepath_mapping.ApiId = ref(http_api.logical_id) basepath_mapping.Stage = ref(http_api.logical_id + ".Stage") - basepath_mapping.ApiMappingKey = path + # ignore leading and trailing `/` in the path name + basepath_mapping.ApiMappingKey = path.strip("/") basepath_resource_list.extend([basepath_mapping]) return basepath_resource_list diff --git a/samtranslator/open_api/open_api.py b/samtranslator/open_api/open_api.py index ab2584f03..4c4dd450a 100644 --- a/samtranslator/open_api/open_api.py +++ b/samtranslator/open_api/open_api.py @@ -219,8 +219,7 @@ def add_path_parameters_to_method(self, api, path, method_name, path_parameters) else: # create as Py27Dict and insert keys one by one to preserve input order parameter = Py27Dict() - param = Py27UniStr(param) if isinstance(param, str) else param - parameter["name"] = param + parameter["name"] = Py27UniStr(param) if isinstance(param, str) else param parameter["in"] = "path" parameter["required"] = True parameters.append(parameter) diff --git a/samtranslator/third_party/py27hash/hash.py b/samtranslator/third_party/py27hash/hash.py index 022a63447..8c84326e7 100644 --- a/samtranslator/third_party/py27hash/hash.py +++ b/samtranslator/third_party/py27hash/hash.py @@ -78,8 +78,7 @@ def thash(value): # type: ignore[no-untyped-def] for y in value: length -= 1 - y = Hash.hash(y) - x = (x ^ y) * mult + x = (x ^ Hash.hash(y)) * mult mult += 82520 + length + length x += 97531 diff --git a/samtranslator/translator/translator.py b/samtranslator/translator/translator.py index 0b5e57b6b..abff0ac5b 100644 --- a/samtranslator/translator/translator.py +++ b/samtranslator/translator/translator.py @@ -328,16 +328,17 @@ def _get_embedded_connectors(self, resources: Dict[str, Any]) -> List[Resource]: for connector_logical_id, connector_dict in resource["Connectors"].items(): try: - connector_logical_id = source_logical_id + connector_logical_id + full_connector_logical_id = source_logical_id + connector_logical_id # can't use sam_expect since this is neither a property nor a resource attribute if not isinstance(connector_dict, dict): raise InvalidResourceException( - connector_logical_id, f"{source_logical_id}.{connector_logical_id} should be a map." + full_connector_logical_id, + f"{source_logical_id}.{full_connector_logical_id} should be a map.", ) generated_connector = self._get_generated_connector( source_logical_id, - connector_logical_id, + full_connector_logical_id, connector_dict, ) diff --git a/samtranslator/utils/py27hash_fix.py b/samtranslator/utils/py27hash_fix.py index abd7de228..ef58bfc6b 100644 --- a/samtranslator/utils/py27hash_fix.py +++ b/samtranslator/utils/py27hash_fix.py @@ -406,12 +406,13 @@ def update(self, *args, **kwargs): # type: ignore[no-untyped-def] """ for arg in args: # Cast to dict if applicable. Otherwise, assume it's an iterable of (key, value) pairs + _arg = arg if isinstance(arg, dict): # Merge incoming keys into keylist self.keylist.merge(arg.keys()) # type: ignore[no-untyped-call] - arg = arg.items() + _arg = arg.items() - for k, v in arg: + for k, v in _arg: self[k] = v for k, v in dict(**kwargs).items():