Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Sep 24, 2023
1 parent 2149b5d commit 027bce0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion openfisca_core/entities/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def set_tax_benefit_system(self, tax_benefit_system: TaxBenefitSystem):
self._tax_benefit_system = tax_benefit_system

def check_role_validity(self, role: Any) -> None:
if role is not None and not type(role) == Role:
if role is not None and not isinstance(role, Role):
raise ValueError("{} is not a valid role".format(role))

def get_variable(
Expand Down
8 changes: 4 additions & 4 deletions openfisca_core/taxbenefitsystems/tax_benefit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def add_variables_from_file(self, file_path):
sys.modules[module_name] = module

lines = linecache.getlines(file_path, module.__dict__)
source = ''.join(lines)
source = "".join(lines)
tree = ast.parse(source)
defs = {i.name: i for i in tree.body if isinstance(i, ast.ClassDef)}
spec.loader.exec_module(module)
Expand All @@ -262,9 +262,9 @@ def add_variables_from_file(self, file_path):
class_def = defs[pot_variable.__name__]
pot_variable.introspection_data = (
source_file_path,
''.join(lines[class_def.lineno-1:class_def.end_lineno]),
class_def.lineno-1
)
"".join(lines[class_def.lineno - 1 : class_def.end_lineno]),
class_def.lineno - 1,
)
self.add_variable(pot_variable)
except Exception:
log.error(
Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/variables/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def get_introspection_data(cls):
try:
return cls.introspection_data
except AttributeError:
return '', None, 0
return "", None, 0

def get_formula(
self,
Expand Down
16 changes: 4 additions & 12 deletions openfisca_web_api/loader/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def build_source_url(
)


def build_formula(
formula, country_package_metadata, source_file_path
):
def build_formula(formula, country_package_metadata, source_file_path):
source_code, start_line_number = inspect.getsourcelines(formula)

source_code = textwrap.dedent("".join(source_code))
Expand All @@ -58,13 +56,9 @@ def build_formula(
return api_formula


def build_formulas(
formulas, country_package_metadata, source_file_path
):
def build_formulas(formulas, country_package_metadata, source_file_path):
return {
start_date: build_formula(
formula, country_package_metadata, source_file_path
)
start_date: build_formula(formula, country_package_metadata, source_file_path)
for start_date, formula in formulas.items()
}

Expand Down Expand Up @@ -97,9 +91,7 @@ def build_variable(variable, country_package_metadata):

if len(variable.formulas) > 0:
result["formulas"] = build_formulas(
variable.formulas,
country_package_metadata,
source_file_path
variable.formulas, country_package_metadata, source_file_path
)

if variable.end:
Expand Down
2 changes: 1 addition & 1 deletion tests/core/tax_scales/test_abstract_rate_tax_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
def test_abstract_tax_scale():
with pytest.warns(DeprecationWarning):
result = taxscales.AbstractRateTaxScale()
assert type(result) == taxscales.AbstractRateTaxScale
assert isinstance(result, taxscales.AbstractRateTaxScale)
2 changes: 1 addition & 1 deletion tests/core/tax_scales/test_abstract_tax_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
def test_abstract_tax_scale():
with pytest.warns(DeprecationWarning):
result = taxscales.AbstractTaxScale()
assert type(result) == taxscales.AbstractTaxScale
assert isinstance(result, taxscales.AbstractTaxScale)

0 comments on commit 027bce0

Please sign in to comment.