Skip to content

Commit

Permalink
Fix pre-existing mypy errors (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Valenzuela authored and garrettheel committed Jul 11, 2018
1 parent 559479b commit 8370150
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
39 changes: 31 additions & 8 deletions awspricing/offers.py
Expand Up @@ -228,6 +228,11 @@ def reserved_hourly(self,
# type: (...) -> float
self._validate_reserved_price_args(
lease_contract_length, offering_class, purchase_option)

assert lease_contract_length is not None
assert offering_class is not None
assert purchase_option is not None

sku = self.get_sku(
instance_type,
operating_system=operating_system,
Expand Down Expand Up @@ -307,6 +312,11 @@ def reserved_upfront(self,
# type: (...) -> float
self._validate_reserved_price_args(
lease_contract_length, offering_class, purchase_option)

assert lease_contract_length is not None
assert offering_class is not None
assert purchase_option is not None

sku = self.get_sku(
instance_type,
operating_system=operating_system,
Expand All @@ -332,9 +342,9 @@ def reserved_upfront(self,

@classmethod
def _validate_reserved_price_args(cls,
lease_contract_length, # type: str
offering_class, # type: str
purchase_option, # type: str
lease_contract_length, # type: Optional[str]
offering_class, # type: Optional[str]
purchase_option, # type: Optional[str]
):
# type: (...) -> None
if lease_contract_length not in EC2_LEASE_CONTRACT_LENGTH.values():
Expand Down Expand Up @@ -385,21 +395,24 @@ def __init__(self, *args, **kwargs):
)

# Lazily-loaded cache to hold offerTermCodes within a SKU
self._reserved_terms_to_offer_term_code = defaultdict(dict)
self._reserved_terms_to_offer_term_code = defaultdict(dict) # type: Dict[str, Dict]

def get_sku(self,
instance_type, # type: str
database_engine, # type: str
license_model=None, # type: str
license_model=None, # type: Optional[str]
deployment_option=None, # type: Optional[str]
database_edition=None, # type: Optional[str]
region=None # type: Optional[str]
):
region = self._normalize_region(region)
deployment_option = deployment_option or self.default_deployment_option

if license_model is None:
raise ValueError("License model is required")

attributes = [instance_type, database_engine,
deployment_option, license_model, region]
deployment_option, license_model, region] # type: List[str]

if database_edition is not None:
attributes.append(database_edition)
Expand Down Expand Up @@ -452,6 +465,11 @@ def reserved_hourly(self,
# type: (...) -> float
self._validate_reserved_price_args(
lease_contract_length, offering_class, purchase_option)

assert lease_contract_length is not None
assert offering_class is not None
assert purchase_option is not None

sku = self.get_sku(
instance_type,
database_engine,
Expand Down Expand Up @@ -531,6 +549,11 @@ def reserved_upfront(self,
# type: (...) -> float
self._validate_reserved_price_args(
lease_contract_length, offering_class, purchase_option)

assert lease_contract_length is not None
assert offering_class is not None
assert purchase_option is not None

sku = self.get_sku(
instance_type,
database_engine,
Expand All @@ -556,9 +579,9 @@ def reserved_upfront(self,

@classmethod
def _validate_reserved_price_args(cls,
lease_contract_length, # type: str
lease_contract_length, # type: Optional[str]
offering_class, # type: str
purchase_option, # type: str
purchase_option, # type: Optional[str]
):
# type: (...) -> None
if lease_contract_length not in RDS_LEASE_CONTRACT_LENGTH.values():
Expand Down
2 changes: 1 addition & 1 deletion mypy-requirements.txt
@@ -1 +1 @@
mypy==0.501
mypy==0.610

0 comments on commit 8370150

Please sign in to comment.