Skip to content

Commit de17734

Browse files
committed
Minor linting improvements - see HEA-688
1 parent 8f3cf74 commit de17734

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

apps/common/lookups.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import pandas as pd
1111
from django.contrib.auth.models import User
12+
from django.db.models import Model
1213

1314
from .fields import translation_fields
1415
from .models import (
@@ -31,7 +32,7 @@ class Lookup(ABC):
3132

3233
# The primary key fields for the model being retrieved, typically
3334
# a single auto-incremented surrogate key named `id`
34-
id_fields = None
35+
id_fields = []
3536

3637
# The fields passed from the dataframe that are used to constrain the lookup,
3738
# typically the fields that are foreign keys from the model being looked up to
@@ -346,7 +347,7 @@ def get(self, value: str, **parent_values) -> str | None:
346347
return None
347348

348349
@functools.cache
349-
def get_instance(self, value: str, **parent_values) -> str | None:
350+
def get_instance(self, value: str, **parent_values) -> Model | None:
350351
"""
351352
Return the Django model instance for a single string, or None if there is no match.
352353

pipelines/assets/livelihood_activity.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,11 @@ def get_instances_from_dataframe(
436436
)
437437
]
438438

439+
# Assertion to prevent linting from complaining about possible None values
440+
assert livelihood_strategy is not None, (
441+
"Found Livelihood Activities from row %s, but there is no Livelihood Strategy defined." % row
442+
)
443+
439444
# Don't save Livelihood Strategies from the Data worksheet that are captured in more detail
440445
# on the Data2 or Data3 worksheets. These strategies have entries in the Data sheet like 'Construction cash income -- see Data2'
441446
if non_empty_livelihood_activities and re.match(

0 commit comments

Comments
 (0)