Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Enable SIM101 + SIM114 #9758

Merged
merged 17 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ def _get_evaluation_dependencies(
{"table.row_count": MetricConfiguration("table.row_count", table_domain_kwargs)}
)

if isinstance(execution_engine, SqlAlchemyExecutionEngine) or isinstance(
execution_engine, SparkDFExecutionEngine
):
if isinstance(execution_engine, (SqlAlchemyExecutionEngine, SparkDFExecutionEngine)):
dependencies["column_values.nonnull.count"] = MetricConfiguration(
"column_values.nonnull.count", metric.metric_domain_kwargs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def validate_configuration(self, configuration: Optional[ExpectationConfiguratio
threshold = self._get_default_value("threshold")

try:
assert isinstance(threshold, int) or isinstance(threshold, float)
assert isinstance(threshold, (int, float))
assert threshold >= 0
assert threshold <= 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def validate_configuration(self, configuration: Optional[ExpectationConfiguratio
isinstance(n_features, int) or n_features is None
), "n_features must be an integer"
if columns is not None:
assert (isinstance(columns, tuple) or isinstance(columns, list)) and all(
assert (isinstance(columns, (tuple, list))) and all(
isinstance(i, str) for i in columns
), "columns must be a tuple or list of string column names"
assert (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def validate_configuration(cls, configuration: Optional[ExpectationConfiguration
assert (
center_point is not None and range is not None
), "center_point and range must be specified"
assert (isinstance(center_point, tuple) or isinstance(center_point, list)) and all(
assert (isinstance(center_point, (tuple, list))) and all(
isinstance(n, float) for n in center_point
), "center_point must be a tuple or list of lat/lon floats"
assert (center_point[0] >= -90 and center_point[0] <= 90) and (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def is_valid_city_name(city: str):
dict_of_cities = geocache.get_cities()
list_of_cities = [d for d in dict_of_cities.values()]
list_of_city_names = [item["name"] for item in list_of_cities]
if len(city) > 54:
return False
elif type(city) != str: # noqa: E721
if len(city) > 54 or type(city) != str: # noqa: E721
return False
elif city in list_of_city_names:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def is_valid_country(country: str):
dict_of_countries = geocache.get_countries()
list_of_countries = [d for d in dict_of_countries.values()]
list_of_country_names = [item["name"] for item in list_of_countries]
if len(country) > 252:
return False
elif type(country) != str: # noqa: E721
if len(country) > 252 or type(country) != str: # noqa: E721
return False
elif country in list_of_country_names:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def is_valid_country_fip(country_fip: str):
list_of_countries = [d for d in dict_of_countries.values()]
list_of_country_fips = [item["fips"] for item in list_of_countries]
cleaned_list_of_country_fips = [string for string in list_of_country_fips if string.strip()]
if len(country_fip) > 2:
return False
elif type(country_fip) != str: # noqa: E721
if len(country_fip) > 2 or type(country_fip) != str: # noqa: E721
return False
elif country_fip in cleaned_list_of_country_fips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def is_valid_us_county_fip(county_fip: str):
geocache = geonamescache.GeonamesCache()
dict_of_counties = geocache.get_us_counties()
list_of_county_fips = [d["fips"] for d in dict_of_counties]
if len(county_fip) > 5:
return False
elif type(county_fip) != str: # noqa: E721
if len(county_fip) > 5 or type(county_fip) != str: # noqa: E721
return False
if county_fip in list_of_county_fips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def is_valid_us_county_name(county: str):
geocache = geonamescache.GeonamesCache()
dict_of_counties = geocache.get_us_counties()
list_of_counties = [d["name"] for d in dict_of_counties if "name" in d]
if len(county) > 33:
return False
elif type(county) != str: # noqa: E721
if len(county) > 33 or type(county) != str: # noqa: E721
return False
if county in list_of_counties:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def is_valid_state(state: str, dc_statehood: bool):
list_of_states.append("District Of Columbia")
else:
pass
if len(state) > 20:
return False
elif type(state) != str: # noqa: E721
if len(state) > 20 or type(state) != str: # noqa: E721
return False
elif state in list_of_states:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def is_valid_state_abbreviation(state: str, dc_statehood: bool):
list_of_state_abbrs.append("DC")
else:
pass
if len(state) != 2:
return False
elif type(state) != str: # noqa: E721
if len(state) != 2 or type(state) != str: # noqa: E721
return False
elif state in list_of_state_abbrs:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def is_valid_state_or_territory(state: str, dc_statehood: bool):
list_of_states_and_territories.append("District Of Columbia")
else:
pass
if len(state) > 24:
return False
elif type(state) != str: # noqa: E721
if len(state) > 24 or type(state) != str: # noqa: E721
return False
elif state in list_of_states_and_territories:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def is_valid_state_or_territory_abbreviation(state: str, dc_statehood: bool):
list_of_state_and_territory_abbrs.append("DC")
else:
pass
if len(state) != 2:
return False
elif type(state) != str: # noqa: E721
if len(state) != 2 or type(state) != str: # noqa: E721
return False
elif state in list_of_state_and_territory_abbrs:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_alabama_zip(zip: str):
list_of_dicts_of_alabama_zips = zipcodes.filter_by(state="AL")
list_of_alabama_zips = [d["zip_code"] for d in list_of_dicts_of_alabama_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_alabama_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_alaska_zip(zip: str):
list_of_dicts_of_alaska_zips = zipcodes.filter_by(state="AK")
list_of_alaska_zips = [d["zip_code"] for d in list_of_dicts_of_alaska_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_alaska_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_validarizonazip(zip: str):
list_of_dicts_ofarizonazips = zipcodes.filter_by(state="AZ")
list_ofarizonazips = [d["zip_code"] for d in list_of_dicts_ofarizonazips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_ofarizonazips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_arkansas_zip(zip: str):
list_of_dicts_of_arkansas_zips = zipcodes.filter_by(state="AR")
list_of_arkansas_zips = [d["zip_code"] for d in list_of_dicts_of_arkansas_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_arkansas_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_california_zip(zip: str):
list_of_dicts_of_california_zips = zipcodes.filter_by(state="CA")
list_of_california_zips = [d["zip_code"] for d in list_of_dicts_of_california_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_california_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_colorado_zip(zip: str):
list_of_dicts_of_colorado_zips = zipcodes.filter_by(state="CO")
list_of_colorado_zips = [d["zip_code"] for d in list_of_dicts_of_colorado_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_colorado_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_connecticut_zip(zip: str):
list_of_dicts_of_connecticut_zips = zipcodes.filter_by(state="CT")
list_of_connecticut_zips = [d["zip_code"] for d in list_of_dicts_of_connecticut_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_connecticut_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_delaware_zip(zip: str):
list_of_dicts_of_delaware_zips = zipcodes.filter_by(state="DE")
list_of_delaware_zips = [d["zip_code"] for d in list_of_dicts_of_delaware_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_delaware_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_florida_zip(zip: str):
list_of_dicts_of_florida_zips = zipcodes.filter_by(state="FL")
list_of_florida_zips = [d["zip_code"] for d in list_of_dicts_of_florida_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_florida_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_georgia_zip(zip: str):
list_of_dicts_of_georgia_zips = zipcodes.filter_by(state="GA")
list_of_georgia_zips = [d["zip_code"] for d in list_of_dicts_of_georgia_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_georgia_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_hawaii_zip(zip: str):
list_of_dicts_of_hawaii_zips = zipcodes.filter_by(state="HI")
list_of_hawaii_zips = [d["zip_code"] for d in list_of_dicts_of_hawaii_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_hawaii_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_idaho_zip(zip: str):
list_of_dicts_of_idaho_zips = zipcodes.filter_by(state="ID")
list_of_idaho_zips = [d["zip_code"] for d in list_of_dicts_of_idaho_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_idaho_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_illinois_zip(zip: str):
list_of_dicts_of_illinois_zips = zipcodes.filter_by(state="IL")
list_of_illinois_zips = [d["zip_code"] for d in list_of_dicts_of_illinois_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_illinois_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@


def is_valid_india_zip(zip: str):
if len(zip) != 6:
return False
elif zip.isnumeric() is False:
if len(zip) != 6 or zip.isnumeric() is False:
return False
elif indiapins.isvalid(zip):
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_indiana_zip(zip: str):
list_of_dicts_of_indiana_zips = zipcodes.filter_by(state="IN")
list_of_indiana_zips = [d["zip_code"] for d in list_of_dicts_of_indiana_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_indiana_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_iowa_zip(zip: str):
list_of_dicts_of_iowa_zips = zipcodes.filter_by(state="IA")
list_of_iowa_zips = [d["zip_code"] for d in list_of_dicts_of_iowa_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_iowa_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_kansas_zip(zip: str):
list_of_dicts_of_kansas_zips = zipcodes.filter_by(state="KS")
list_of_kansas_zips = [d["zip_code"] for d in list_of_dicts_of_kansas_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_kansas_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_kentucky_zip(zip: str):
list_of_dicts_of_kentucky_zips = zipcodes.filter_by(state="KY")
list_of_kentucky_zips = [d["zip_code"] for d in list_of_dicts_of_kentucky_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_kentucky_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_louisiana_zip(zip: str):
list_of_dicts_of_louisiana_zips = zipcodes.filter_by(state="LA")
list_of_louisiana_zips = [d["zip_code"] for d in list_of_dicts_of_louisiana_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_louisiana_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_maine_zip(zip: str):
list_of_dicts_of_maine_zips = zipcodes.filter_by(state="ME")
list_of_maine_zips = [d["zip_code"] for d in list_of_dicts_of_maine_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_maine_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_maryland_zip(zip: str):
list_of_dicts_of_maryland_zips = zipcodes.filter_by(state="MD")
list_of_maryland_zips = [d["zip_code"] for d in list_of_dicts_of_maryland_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_maryland_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_massachusetts_zip(zip: str):
list_of_dicts_of_massachusetts_zips = zipcodes.filter_by(state="MA")
list_of_massachusetts_zips = [d["zip_code"] for d in list_of_dicts_of_massachusetts_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_massachusetts_zips:
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
def is_valid_michigan_zip(zip: str):
list_of_dicts_of_michigan_zips = zipcodes.filter_by(state="MI")
list_of_michigan_zips = [d["zip_code"] for d in list_of_dicts_of_michigan_zips]
if len(zip) > 10:
return False
elif type(zip) != str: # noqa: E721
if len(zip) > 10 or type(zip) != str: # noqa: E721
return False
elif zip in list_of_michigan_zips:
return True
Expand Down