Skip to content

Commit

Permalink
chore: bump deps (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
tekumara authored Mar 13, 2023
1 parent 225ef16 commit 599f3eb
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
entry: .venv/bin/black
language: system
types: [python]
# use docformatter from the venv so that it reads from pyproject.toml (which requires tomli)
# use docformatter from the venv so that it reads from pyproject.toml
- id: docformatter
name: docformatter
entry: .venv/bin/docformatter
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $(pip):
# create venv using system python even when another venv is active
PATH=$${PATH#$${VIRTUAL_ENV}/bin:} python3 -m venv --clear $(venv)
$(venv)/bin/python --version
$(pip) install pip~=22.2
$(pip) install pip~=23.0

$(venv): pyproject.toml $(pip)
$(pip) install -e '.[dev]'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"devDependencies": {
"pyright": "1.1.277"
"pyright": "1.1.298"
}
}
34 changes: 14 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@ keywords = ["AWS", "EC2", "command line", "cli"]
classifiers = ["License :: OSI Approved :: MIT License"]
requires-python = ">=3.7"
dependencies = [
"boto3==1.24.41",
"importlib_resources==5.9.0",
"boto3==1.26.89",
"importlib_resources==5.12.0",
"pytoml==0.1.21",
"pytz==2022.1",
"requests==2.28.1",
"rich==12.5.1",
"typing_extensions==4.3.0",
"pytz==2022.7.1",
"requests==2.28.2",
"rich==13.3.2",
"typing_extensions==4.5.0",
]

[project.optional-dependencies]
dev = [
"autoflake~=1.7",
"black~=22.6",
"black~=23.1",
"build~=0.7",
"boto3-stubs[ec2,compute-optimizer,ssm,s3]==1.24.41",
"boto3-stubs[ec2,compute-optimizer,ssm,s3]==1.26.89",
"cogapp~=3.3",
"darglint~=1.8",
"docformatter[toml]~=1.5.0",
"moto[ec2]==3.1.16",
"docformatter~=1.5",
"moto[ec2]==4.1.4",
"pre-commit~=2.20",
"pyfakefs~=4.6",
"pytest~=7.1",
"pyfakefs~=5.1",
"pytest~=7.2",
"pytest-mock~=3.8",
"ruff~=0.0.235",
"ruff~=0.0.254",
"twine~=4.0",
]

Expand All @@ -47,12 +46,6 @@ requires = ["setuptools", "wheel"]
[tool.setuptools.dynamic]
version = { attr = "aec.__version__" }

[tool.autoflake]
in-place = true
recursive = true
remove-all-unused-imports = true
ignore-init-module-imports = true

[tool.black]
# use PyCharm default line length of 120
line-length = 120
Expand Down Expand Up @@ -99,6 +92,7 @@ src = ["src"]
# pyupgrade target
target-version = "py37"
fix = true
show-fixes = true

[tool.ruff.pyupgrade]
# Preserve types, even if a file imports `from __future__ import annotations`.
Expand Down
2 changes: 1 addition & 1 deletion src/aec/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.7.2"
__version__ = "2.7.3"
20 changes: 10 additions & 10 deletions src/aec/util/ec2_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class _RequiredRunArgs(TypedDict, total=True):


class RunArgs(_RequiredRunArgs, total=False):
BlockDeviceMappings: List["BlockDeviceMappingTypeDef"]
BlockDeviceMappings: List[BlockDeviceMappingTypeDef]
ImageId: str
InstanceType: InstanceTypeType
Ipv6AddressCount: int
Ipv6Addresses: List["InstanceIpv6AddressTypeDef"]
Ipv6Addresses: List[InstanceIpv6AddressTypeDef]
KernelId: str
KeyName: str
Monitoring: "RunInstancesMonitoringEnabledTypeDef"
Placement: "PlacementTypeDef"
Monitoring: RunInstancesMonitoringEnabledTypeDef
Placement: PlacementTypeDef
RamdiskId: str
SecurityGroupIds: List[str]
SecurityGroups: List[str]
Expand All @@ -54,16 +54,16 @@ class RunArgs(_RequiredRunArgs, total=False):
DisableApiTermination: bool
DryRun: bool
EbsOptimized: bool
IamInstanceProfile: "IamInstanceProfileSpecificationTypeDef"
IamInstanceProfile: IamInstanceProfileSpecificationTypeDef
InstanceInitiatedShutdownBehavior: ShutdownBehaviorType
NetworkInterfaces: List["InstanceNetworkInterfaceSpecificationTypeDef"]
NetworkInterfaces: List[InstanceNetworkInterfaceSpecificationTypeDef]
PrivateIpAddress: str
ElasticGpuSpecification: List["ElasticGpuSpecificationTypeDef"]
ElasticGpuSpecification: List[ElasticGpuSpecificationTypeDef]
ElasticInferenceAccelerators: List[ElasticInferenceAcceleratorTypeDef]
TagSpecifications: List["TagSpecificationTypeDef"]
TagSpecifications: List[TagSpecificationTypeDef]
LaunchTemplate: LaunchTemplateSpecificationTypeDef
InstanceMarketOptions: InstanceMarketOptionsRequestTypeDef
CreditSpecification: "CreditSpecificationRequestTypeDef"
CreditSpecification: CreditSpecificationRequestTypeDef
CpuOptions: CpuOptionsRequestTypeDef
CapacityReservationSpecification: CapacityReservationSpecificationTypeDef
HibernationOptions: HibernationOptionsRequestTypeDef
Expand All @@ -73,7 +73,7 @@ class RunArgs(_RequiredRunArgs, total=False):


class DescribeArgs(TypedDict, total=False):
Filters: Sequence["FilterTypeDef"]
Filters: Sequence[FilterTypeDef]
InstanceIds: Sequence[str]
DryRun: bool
MaxResults: int
Expand Down
5 changes: 2 additions & 3 deletions tests/test_compute_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
def mock_aws_config():
mock = mock_ec2()
mock.start()
region = "ap-southeast-2"
region = "us-east-1"

return {
"region": region,
"additional_tags": {"Owner": "[email protected]", "Project": "test project a"},
"key_name": "test_key",
"vpc": {
"name": "test vpc",
"subnet": next(ec2_backends[region].get_all_subnets()).id,
"subnet": ec2_backends["123456789012"]["us-east-1"].get_default_subnet("us-east-1a").id,
"security_group": "default",
},
"iam_instance_profile_arn": "test_profile",
}


Expand Down
5 changes: 4 additions & 1 deletion tests/test_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def test_as_table_infer_keys():


def test_as_table_with_datetime():
assert as_table([{"a": 1, "b": datetime.datetime(2019, 8, 19, 6, 3, 6, tzinfo=tzutc())}], ["a", "b"],) == [
assert as_table(
[{"a": 1, "b": datetime.datetime(2019, 8, 19, 6, 3, 6, tzinfo=tzutc())}],
["a", "b"],
) == [
["a", "b"],
["1", "2019-08-19 06:03:06+00:00"],
]
Expand Down
23 changes: 17 additions & 6 deletions tests/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import boto3
import pytest
from moto import mock_ec2
from moto import mock_ec2, mock_iam
from moto.ec2 import ec2_backends
from moto.ec2.models.amis import AMIS
from mypy_boto3_ec2.type_defs import TagTypeDef
Expand Down Expand Up @@ -32,17 +32,16 @@
def mock_aws_config() -> Config:
mock = mock_ec2()
mock.start()
region = "ap-southeast-2"
region = "us-east-1"

return {
"region": region,
"key_name": "test_key",
"vpc": {
"name": "test vpc",
"subnet": next(ec2_backends[region].get_all_subnets()).id,
"subnet": ec2_backends["123456789012"]["us-east-1"].get_default_subnet("us-east-1a").id,
"security_group": "default",
},
"iam_instance_profile_arn": "test_profile",
}


Expand Down Expand Up @@ -93,14 +92,26 @@ def test_launch_multiple_security_groups(mock_aws_config: Config):
print(launch(mock_aws_config, "alice", ami_id))


def test_launch_without_instance_profile(mock_aws_config: Config):
del mock_aws_config["iam_instance_profile_arn"]
@mock_iam
def test_launch_with_instance_profile(mock_aws_config: Config):
iam = boto3.client("iam", "us-east-1")

profile = iam.create_instance_profile(
InstanceProfileName="test-profile",
)

mock_aws_config["iam_instance_profile_arn"] = profile["InstanceProfile"]["Arn"]
print(launch(mock_aws_config, "alice", ami_id))


def test_launch_no_region_specified(mock_aws_config: Config):
del mock_aws_config["region"]
os.environ["AWS_DEFAULT_REGION"] = "ap-southeast-2"

mock_aws_config["vpc"]["subnet"] = (
ec2_backends["123456789012"]["ap-southeast-2"].get_default_subnet("ap-southeast-2a").id
)

instances = launch(mock_aws_config, "alice", ami_id)
assert "amazonaws.com" in instances[0]["DnsName"]

Expand Down

0 comments on commit 599f3eb

Please sign in to comment.