added imports at the top of the file instead of function

This commit is contained in:
Jun-te Kim 2026-05-12 09:37:23 +00:00
parent 1934c889b0
commit 5edae06a65

View file

@ -20,12 +20,15 @@ from backend.utils.addressMatch import (
df_has_single_uprn,
score_addresses,
)
from datatypes.epc.domain.historic_epc_matching import (
match_addresses_for_postcode,
)
from backend.epc_client.client import EpcClientService
logger = setup_logger()
def get_epc_data_with_postcode(postcode: str) -> pd.DataFrame:
from backend.epc_client.client import EpcClientService
token = os.getenv("OPEN_EPC_API_TOKEN")
if token is None:
@ -51,9 +54,6 @@ def get_uprn_from_historic_epc(
here because historic addresses use a more verbose format that
systematically depresses lexiscores.
"""
from datatypes.epc.domain.historic_epc_matching import (
match_addresses_for_postcode,
)
try:
result = match_addresses_for_postcode(user_inputed_address, postcode)
@ -148,9 +148,7 @@ def get_uprn(
postcode=postcode,
)
if result:
logger.info(
f"Historic EPC matched {user_inputed_address} in {postcode}"
)
logger.info(f"Historic EPC matched {user_inputed_address} in {postcode}")
if not result:
return None
@ -427,7 +425,6 @@ def handler(event, context, local=False):
)
continue
# Process each address in this postcode with the same EPC data
for row in postcode_rows:
try: