Skip to content

Commit

Permalink
switch to ruff and upgrade test tooling (localstack#9399)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrashed authored Oct 20, 2023
1 parent 05a52a1 commit e74ff43
Show file tree
Hide file tree
Showing 176 changed files with 174 additions and 331 deletions.
1 change: 1 addition & 0 deletions .github/workflows/asf-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
run: |
source .venv/bin/activate
python3 -m localstack.aws.scaffold upgrade
make format-modified
- name: Check for changes
id: check-for-changes
Expand Down
27 changes: 7 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,19 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.10.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.0
hooks:
- id: isort
name: isort (python)
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
entry: pflake8
additional_dependencies:
- pyproject-flake8
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,19 @@ test-docker-mount-code:
DOCKER_FLAGS="$(DOCKER_FLAGS) --entrypoint= -v `pwd`/localstack/config.py:/opt/code/localstack/localstack/config.py -v `pwd`/localstack/constants.py:/opt/code/localstack/localstack/constants.py -v `pwd`/localstack/utils:/opt/code/localstack/localstack/utils -v `pwd`/localstack/services:/opt/code/localstack/localstack/services -v `pwd`/localstack/aws:/opt/code/localstack/localstack/aws -v `pwd`/Makefile:/opt/code/localstack/Makefile -v $$PACKAGES_DIR/moto:/opt/code/localstack/.venv/lib/python3.11/site-packages/moto/ -e TEST_PATH=\\'$(TEST_PATH)\\' -e LAMBDA_JAVA_OPTS=$(LAMBDA_JAVA_OPTS) $(ENTRYPOINT)" CMD="make test" make docker-run

lint: ## Run code linter to check code style
($(VENV_RUN); python -m pflake8 --show-source)
($(VENV_RUN); python -m ruff check --show-source .)

lint-modified: ## Run code linter on modified files
($(VENV_RUN); python -m pflake8 --show-source `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs` )
($(VENV_RUN); python -m ruff check --show-source `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs` )

check-aws-markers: ## Lightweight check to ensure all AWS tests have proper compatibilty markers set
($(VENV_RUN); python -m pytest --co tests/aws/)

format: ## Run black and isort code formatter
($(VENV_RUN); python -m isort localstack tests; python -m black localstack tests )
format: ## Run black and ruff code formatter
($(VENV_RUN); python -m ruff check --show-source --fix .; python -m black .)

format-modified: ## Run black and isort code formatter on modified files
($(VENV_RUN); python -m isort `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs`; python -m black `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs` )
format-modified: ## Run black and ruff code formatter on modified files
($(VENV_RUN); python -m ruff check --show-source --fix `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs`; python -m black `git diff --diff-filter=d --name-only HEAD | grep '\.py$$' | xargs` )

init-precommit: ## install te pre-commit hook into your local git repository
($(VENV_RUN); pre-commit install)
Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/acm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ class UpdateCertificateOptionsRequest(ServiceRequest):


class AcmApi:

service = "acm"
version = "2015-12-08"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/apigateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,6 @@ class VpcLinks(TypedDict, total=False):


class ApigatewayApi:

service = "apigateway"
version = "2015-07-09"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/cloudcontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ class UpdateResourceOutput(TypedDict, total=False):


class CloudcontrolApi:

service = "cloudcontrol"
version = "2021-09-30"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/cloudformation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,6 @@ class ValidateTemplateOutput(TypedDict, total=False):


class CloudformationApi:

service = "cloudformation"
version = "2010-05-15"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/cloudwatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ class UntagResourceOutput(TypedDict, total=False):


class CloudwatchApi:

service = "cloudwatch"
version = "2010-08-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,6 @@ class UntagResourceRequest(ServiceRequest):


class ConfigApi:

service = "config"
version = "2014-11-12"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/dynamodb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,6 @@ class UpdateTimeToLiveOutput(TypedDict, total=False):


class DynamodbApi:

service = "dynamodb"
version = "2012-08-10"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/dynamodbstreams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ class ListStreamsOutput(TypedDict, total=False):


class DynamodbstreamsApi:

service = "dynamodbstreams"
version = "2012-08-10"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/ec2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17540,7 +17540,6 @@ class WithdrawByoipCidrResult(TypedDict, total=False):


class Ec2Api:

service = "ec2"
version = "2016-11-15"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,6 @@ class UpgradeElasticsearchDomainResponse(TypedDict, total=False):


class EsApi:

service = "es"
version = "2015-01-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,6 @@ class UpdateEndpointResponse(TypedDict, total=False):


class EventsApi:

service = "events"
version = "2015-10-07"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/firehose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,6 @@ class UpdateDestinationOutput(TypedDict, total=False):


class FirehoseApi:

service = "firehose"
version = "2015-08-04"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/iam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +2279,6 @@ class UploadSigningCertificateResponse(TypedDict, total=False):


class IamApi:

service = "iam"
version = "2010-05-08"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/kinesis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ class UpdateStreamModeInput(ServiceRequest):


class KinesisApi:

service = "kinesis"
version = "2013-12-02"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/kms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,6 @@ class VerifyResponse(TypedDict, total=False):


class KmsApi:

service = "kms"
version = "2014-11-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/lambda_/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,6 @@ class UpdateFunctionUrlConfigResponse(TypedDict, total=False):


class LambdaApi:

service = "lambda"
version = "2015-03-31"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ class UntagResourceRequest(ServiceRequest):


class LogsApi:

service = "logs"
version = "2014-03-28"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/opensearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,6 @@ class UpgradeDomainResponse(TypedDict, total=False):


class OpensearchApi:

service = "opensearch"
version = "2021-01-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/ram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,6 @@ class UpdateResourceShareResponse(TypedDict, total=False):


class RamApi:

service = "ram"
version = "2018-01-04"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/redshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3119,7 +3119,6 @@ class UsageLimitList(TypedDict, total=False):


class RedshiftApi:

service = "redshift"
version = "2012-12-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/resource_groups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ class UpdateGroupQueryOutput(TypedDict, total=False):


class ResourceGroupsApi:

service = "resource-groups"
version = "2017-11-27"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/resourcegroupstaggingapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class UntagResourcesOutput(TypedDict, total=False):


class ResourcegroupstaggingapiApi:

service = "resourcegroupstaggingapi"
version = "2017-01-26"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/route53/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,6 @@ class UpdateTrafficPolicyInstanceResponse(TypedDict, total=False):


class Route53Api:

service = "route53"
version = "2013-04-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/route53resolver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ class UpdateResolverRuleResponse(TypedDict, total=False):


class Route53ResolverApi:

service = "route53resolver"
version = "2018-04-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/s3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,6 @@ class PostResponse(TypedDict, total=False):


class S3Api:

service = "s3"
version = "2006-03-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/s3control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,6 @@ class UpdateJobStatusResult(TypedDict, total=False):


class S3ControlApi:

service = "s3control"
version = "2018-08-20"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/scheduler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ class UpdateScheduleOutput(TypedDict, total=False):


class SchedulerApi:

service = "scheduler"
version = "2021-06-30"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/secretsmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ class ValidateResourcePolicyResponse(TypedDict, total=False):


class SecretsmanagerApi:

service = "secretsmanager"
version = "2017-10-17"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/ses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,6 @@ class VerifyEmailIdentityResponse(TypedDict, total=False):


class SesApi:

service = "ses"
version = "2010-12-01"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/sns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ class VerifySMSSandboxPhoneNumberResult(TypedDict, total=False):


class SnsApi:

service = "sns"
version = "2010-03-31"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/sqs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ class UntagQueueRequest(ServiceRequest):


class SqsApi:

service = "sqs"
version = "2012-11-05"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/ssm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5477,7 +5477,6 @@ class UpdateServiceSettingResult(TypedDict, total=False):


class SsmApi:

service = "ssm"
version = "2014-11-06"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/stepfunctions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ class UpdateStateMachineOutput(TypedDict, total=False):


class StepfunctionsApi:

service = "stepfunctions"
version = "2016-11-23"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/sts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class GetSessionTokenResponse(TypedDict, total=False):


class StsApi:

service = "sts"
version = "2011-06-15"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ class ResolveCaseResponse(TypedDict, total=False):


class SupportApi:

service = "support"
version = "2013-04-15"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/swf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,6 @@ class WorkflowTypeInfos(TypedDict, total=False):


class SwfApi:

service = "swf"
version = "2012-01-25"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/api/transcribe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ class UpdateVocabularyResponse(TypedDict, total=False):


class TranscribeApi:

service = "transcribe"
version = "2017-10-26"

Expand Down
1 change: 0 additions & 1 deletion localstack/aws/protocol/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Error(NamedTuple):


class ParameterValidationError(Exception):

error: Error

def __init__(self, error: Error) -> None:
Expand Down
Loading

0 comments on commit e74ff43

Please sign in to comment.