Skip to content

Commit 7262fc4

Browse files
authored
chore(tests): Update precommit config yaml file to newest versions (#206)
* Add mypy.ini file to ignore type errors for setuptools * Updated pre-commit, linting updates from pre-commit update, patch auto_spec updated to autospec in tests/lib/metrics_test.py * moved flake8 our of pre-commit section to its own repo in pre-commit-config * precommit hook versions set to latest to still support python 3.6
1 parent bc9cc9e commit 7262fc4

27 files changed

+101
-97
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@ exclude: ^(buildspec.yml|.pre-commit-config.yaml)$
22
fail_fast: true
33
repos:
44
- repo: https://github.com/pre-commit/mirrors-isort
5-
rev: v4.3.17
5+
rev: v5.10.1
66
hooks:
77
- id: isort
88
# language_version: python3.6
99
- repo: https://github.com/psf/black
10-
rev: 22.3.0
10+
rev: 22.8.0
1111
hooks:
1212
- id: black
1313
exclude: templates/
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v2.0.0
15+
rev: v4.1.0
1616
hooks:
1717
- id: check-case-conflict
1818
- id: end-of-file-fixer
1919
- id: mixed-line-ending
2020
args:
2121
- --fix=lf
2222
- id: trailing-whitespace
23+
- id: pretty-format-json
24+
args:
25+
- --autofix
26+
- --indent=4
27+
- --no-sort-keys
28+
- id: check-merge-conflict
29+
- id: check-yaml
30+
- repo: https://github.com/pycqa/flake8
31+
rev: "5.0.4"
32+
hooks:
2333
- id: flake8
2434
additional_dependencies:
2535
- flake8-bugbear>=19.3.0
@@ -30,28 +40,21 @@ repos:
3040
- flake8-pep3101>=1.2.1
3141
# language_version: python3.6
3242
exclude: templates/
33-
- id: pretty-format-json
34-
args:
35-
- --autofix
36-
- --indent=4
37-
- --no-sort-keys
38-
- id: check-merge-conflict
39-
- id: check-yaml
4043
- repo: https://github.com/pre-commit/pygrep-hooks
41-
rev: v1.3.0
44+
rev: v1.9.0
4245
hooks:
4346
- id: python-check-blanket-noqa
4447
- id: python-check-mock-methods
4548
- id: python-no-log-warn
4649
- repo: https://github.com/PyCQA/bandit
47-
rev: "1.6.2"
50+
rev: "1.7.1"
4851
hooks:
4952
- id: bandit
5053
files: ^(src|python)/
5154
additional_dependencies:
5255
- "importlib-metadata<5" # https://github.com/PyCQA/bandit/issues/956
5356
- repo: https://github.com/pre-commit/mirrors-mypy
54-
rev: v0.790
57+
rev: v0.812
5558
hooks:
5659
- id: mypy
5760
files: ^src/

mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[mypy]
2+
3+
# Per-module options:
4+
[mypy-setuptools.*]
5+
ignore_missing_imports = True

python/rpdk/python/codegen.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1+
import docker
12
import logging
23
import os
34
import shutil
45
import zipfile
5-
from pathlib import PurePosixPath
6-
from subprocess import PIPE, CalledProcessError, run as subprocess_run # nosec
7-
from tempfile import TemporaryFile
8-
from typing import Dict
9-
10-
import docker
116
from docker.errors import APIError, ContainerError, ImageLoadError
7+
from pathlib import PurePosixPath
128
from requests.exceptions import ConnectionError as RequestsConnectionError
139
from rpdk.core.data_loaders import resource_stream
1410
from rpdk.core.exceptions import DownstreamError, SysExitRecommendedError
1511
from rpdk.core.init import input_with_validation
1612
from rpdk.core.jsonutils.resolver import ContainerType, resolve_models
1713
from rpdk.core.plugin_base import LanguagePlugin
1814
from rpdk.core.project import ARTIFACT_TYPE_HOOK
15+
from subprocess import PIPE, CalledProcessError, run as subprocess_run # nosec
16+
from tempfile import TemporaryFile
17+
from typing import Dict
1918

2019
from . import __version__
2120
from .resolver import contains_model, translate_type

python/rpdk/python/templates/handlers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
from typing import Any, MutableMapping, Optional
3-
43
from {{support_lib_pkg}} import (
54
Action,
65
HandlerErrorCode,

python/rpdk/python/templates/hook_handlers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
from typing import Any, MutableMapping, Optional
3-
43
from {{support_lib_pkg}} import (
54
BaseHookHandlerRequest,
65
HandlerErrorCode,

python/rpdk/python/templates/hook_models.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# DO NOT modify this file by hand, changes will be overwritten
2-
import sys
32
from dataclasses import dataclass
3+
4+
from cloudformation_cli_python_lib.interface import BaseHookHandlerRequest, BaseModel
5+
from cloudformation_cli_python_lib.recast import recast_object
6+
from cloudformation_cli_python_lib.utils import deserialize_list
7+
8+
import sys
49
from inspect import getmembers, isclass
510
from typing import (
611
AbstractSet,
@@ -14,10 +19,6 @@
1419
TypeVar,
1520
)
1621

17-
from cloudformation_cli_python_lib.interface import BaseHookHandlerRequest, BaseModel
18-
from cloudformation_cli_python_lib.recast import recast_object
19-
from cloudformation_cli_python_lib.utils import deserialize_list
20-
2122
T = TypeVar("T")
2223

2324

python/rpdk/python/templates/models.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# DO NOT modify this file by hand, changes will be overwritten
2-
import sys
32
from dataclasses import dataclass
3+
4+
from cloudformation_cli_python_lib.interface import (
5+
BaseModel,
6+
BaseResourceHandlerRequest,
7+
)
8+
from cloudformation_cli_python_lib.recast import recast_object
9+
from cloudformation_cli_python_lib.utils import deserialize_list
10+
11+
import sys
412
from inspect import getmembers, isclass
513
from typing import (
614
AbstractSet,
@@ -14,13 +22,6 @@
1422
TypeVar,
1523
)
1624

17-
from cloudformation_cli_python_lib.interface import (
18-
BaseModel,
19-
BaseResourceHandlerRequest,
20-
)
21-
from cloudformation_cli_python_lib.recast import recast_object
22-
from cloudformation_cli_python_lib.utils import deserialize_list
23-
2425
T = TypeVar("T")
2526

2627

python/rpdk/python/templates/target_model.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# DO NOT modify this file by hand, changes will be overwritten
2-
import sys
32
from dataclasses import dataclass
3+
4+
from cloudformation_cli_python_lib.interface import BaseModel
5+
from cloudformation_cli_python_lib.recast import recast_object
6+
from cloudformation_cli_python_lib.utils import deserialize_list
7+
8+
import sys
49
from inspect import getmembers, isclass
510
from typing import (
611
AbstractSet,
@@ -14,10 +19,6 @@
1419
TypeVar,
1520
)
1621

17-
from cloudformation_cli_python_lib.interface import BaseModel
18-
from cloudformation_cli_python_lib.recast import recast_object
19-
from cloudformation_cli_python_lib.utils import deserialize_list
20-
2122
T = TypeVar("T")
2223

2324

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""Python 3.6 and 3.7 language support for the CloudFormation CLI"""
33
import os.path
44
import re
5-
65
from setuptools import setup
76

87
HERE = os.path.abspath(os.path.dirname(__file__))

src/cloudformation_cli_python_lib/boto3_proxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# boto3 doesn't have stub files
2-
from typing import Optional
3-
42
from boto3.session import Session # type: ignore
53

4+
from typing import Optional
5+
66
from .utils import Credentials
77

88

0 commit comments

Comments
 (0)