From 493d264b783b35a779d4a96bb80b79899e0cb610 Mon Sep 17 00:00:00 2001 From: leodube-aot Date: Wed, 31 Jan 2024 16:02:22 -0800 Subject: [PATCH] Fix linting issues entity_filer --- .../src/entity_filer/filing_processors/conversion.py | 11 +++++++---- .../filing_processors/filing_components/__init__.py | 3 +-- .../filing_components/alternate_name.py | 2 +- .../filing_components/name_request.py | 4 +++- .../filing_processors/filing_components/parties.py | 2 +- .../filing_components/rules_and_memorandum.py | 2 +- .../filing_processors/incorporation_filing.py | 2 +- .../entity_filer/filing_processors/registration.py | 6 ++++-- .../entity-filer/src/entity_filer/resources/worker.py | 2 +- queue_services/entity-filer/tests/conftest.py | 2 +- .../filing_components/test_parties_entity_roles.py | 2 +- .../tests/unit/filing_processors/test_admin_freeze.py | 2 +- .../unit/filing_processors/test_annual_report.py | 3 --- .../tests/unit/filing_processors/test_dissolution.py | 3 --- .../filing_processors/test_incorporation_filing.py | 6 ++++-- .../tests/unit/filing_processors/test_put_back_on.py | 2 -- .../entity-filer/tests/unit/worker/test_conversion.py | 1 - .../tests/unit/worker/test_incorporation.py | 2 +- 18 files changed, 28 insertions(+), 29 deletions(-) diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/conversion.py b/queue_services/entity-filer/src/entity_filer/filing_processors/conversion.py index dce9d0926e..240e860c4e 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/conversion.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/conversion.py @@ -58,10 +58,13 @@ def process( ) # if legal_entity and legal_entity.entity_type in ['SP', 'GP']: if filing["filing"]["business"]["legalType"] in ["SP", "GP"]: - if legal_entity and not legal_entity.entity_type in [ - LegalEntity.EntityTypes.PERSON, - LegalEntity.EntityTypes.PARTNERSHIP, - ]: + if legal_entity and not ( + legal_entity.entity_type + in [ + LegalEntity.EntityTypes.PERSON, + LegalEntity.EntityTypes.PARTNERSHIP, + ] + ): raise DefaultException(f"Filing business type and entity don't match, filing{filing_rec.id}") _process_firms_conversion(legal_entity, filing, filing_rec, filing_meta) else: diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/__init__.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/__init__.py index 5e466d488b..88d651624d 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/__init__.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/__init__.py @@ -124,8 +124,7 @@ def merge_party(legal_entity_id: int, party_info: dict, create: bool = True) -> def create_entity_party(legal_entity_id: int, party_info: dict, create: bool = True) -> LegalEntity: """Create a new party or get them if they already exist.""" - # HERE - legal_entity = None + if not (middle_initial := party_info["officer"].get("middleInitial")): middle_initial = party_info["officer"].get("middleName", "") diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/alternate_name.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/alternate_name.py index 743ff747d0..7fac8185dc 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/alternate_name.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/alternate_name.py @@ -18,7 +18,7 @@ from typing import Dict, List, Optional, Tuple import dpath -from business_model import AlternateName, Filing, LegalEntity, db +from business_model import AlternateName, Filing, LegalEntity from entity_filer import db from entity_filer.exceptions import DefaultException diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/name_request.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/name_request.py index cbf85d5358..7d38565bd0 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/name_request.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/name_request.py @@ -30,7 +30,9 @@ def consume_nr(business: LegalEntity, filing: Filing, filing_type="incorporation """Update the nr to a consumed state.""" try: # skip this if none (nrNumber will not be available for numbered company) - if nr_num := get_str(filing.filing_json, f"/filing/{filing_type}/nameRequest/nrNumber"): + if nr_num := get_str( + filing.filing_json, f"/filing/{filing_type}/nameRequest/nrNumber" + ): # noqa F841; remove this comment when below is done pass # TODO Consume NR diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/parties.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/parties.py index 977b21e692..e4d916c318 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/parties.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/parties.py @@ -248,7 +248,7 @@ def merge_all_parties(legal_entity: LegalEntity, filing: Filing, parties: dict) ) case "Proprietor": - print(f"Proprietor role being skipped.") + print("Proprietor role being skipped.") case _: errors.append({"warning": f"role: {role_type} not assigned to party:{party_le}"}) diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/rules_and_memorandum.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/rules_and_memorandum.py index 157a87cf74..c4431ed2f9 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/rules_and_memorandum.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/rules_and_memorandum.py @@ -73,7 +73,7 @@ def update_memorandum( # if nothing is passed in, we don't care and it's not an error return None - is_correction = filing.filing_type == "correction" + is_correction = filing.filing_type == "correction" # noqa F841; remove this comment when below is done # create certified copy for memorandum document # memorandum_file = MinioService.get_file(memorandum_file_key) # registrar_stamp_data = RegistrarStampData(filing.effective_date, business.identifier, file_name, is_correction) diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/incorporation_filing.py b/queue_services/entity-filer/src/entity_filer/filing_processors/incorporation_filing.py index 549627d2cd..25c115e488 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/incorporation_filing.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/incorporation_filing.py @@ -75,7 +75,7 @@ def update_affiliation(business: LegalEntity, filing: Filing): def _update_cooperative(incorp_filing: Dict, business: LegalEntity, filing: Filing): - cooperative_obj = incorp_filing.get("cooperative", None) + cooperative_obj = incorp_filing.get("cooperative", None) # noqa F841; remove this comment when below is done # TODO remove all this # if cooperative_obj: # # create certified copy for rules document diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/registration.py b/queue_services/entity-filer/src/entity_filer/filing_processors/registration.py index 5047e0fc1f..b3a32f1e89 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/registration.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/registration.py @@ -41,10 +41,12 @@ def update_affiliation(business: LegalEntity, filing: Filing): """Create an affiliation for the business and remove the bootstrap.""" try: bootstrap = RegistrationBootstrap.find_by_identifier(filing.temp_reg) - pass_code = legal_entity_info.get_firm_affiliation_passcode(business.id) + pass_code = legal_entity_info.get_firm_affiliation_passcode( + business.id + ) # noqa F841; remove this comment when below is done nr_number = filing.filing_json.get("filing").get("registration", {}).get("nameRequest", {}).get("nrNumber") - details = { + details = { # noqa F841; remove this comment when below is done "bootstrapIdentifier": bootstrap.identifier, "identifier": business.identifier, "nrNumber": nr_number, diff --git a/queue_services/entity-filer/src/entity_filer/resources/worker.py b/queue_services/entity-filer/src/entity_filer/resources/worker.py index 99d12cbd71..a357d3bcb8 100644 --- a/queue_services/entity-filer/src/entity_filer/resources/worker.py +++ b/queue_services/entity-filer/src/entity_filer/resources/worker.py @@ -113,7 +113,7 @@ def worker(): # ## try: process_filing(filing_message) - except (AttributeError, BusinessException, DefaultException) as err: + except (AttributeError, BusinessException, DefaultException) as err: # noqa F841 return {"error": f"Unable to process filing: {filing_message}"}, HTTPStatus.BAD_REQUEST structured_log(request, "INFO", f"completed ce: {str(ce)}") diff --git a/queue_services/entity-filer/tests/conftest.py b/queue_services/entity-filer/tests/conftest.py index 01357e7404..9765060793 100644 --- a/queue_services/entity-filer/tests/conftest.py +++ b/queue_services/entity-filer/tests/conftest.py @@ -207,7 +207,7 @@ def db(app): # pylint: disable=redefined-outer-name, invalid-name dir_path = os.path.dirname(business_model_migrations.__file__) - migrate = Migrate(app, _db, directory=dir_path, **{"dialect_name": "postgres"}) + migrate = Migrate(app, _db, directory=dir_path, **{"dialect_name": "postgres"}) # noqa F841 upgrade() yield _db diff --git a/queue_services/entity-filer/tests/unit/filing_processors/filing_components/test_parties_entity_roles.py b/queue_services/entity-filer/tests/unit/filing_processors/filing_components/test_parties_entity_roles.py index 5c2b374ad0..98e2c81691 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/filing_components/test_parties_entity_roles.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/filing_components/test_parties_entity_roles.py @@ -37,7 +37,7 @@ Director X CUD Incorporator X X CU CU Liquidator X CUD - Partner X X CUD + Partner X X CUD Proprietor X X C """ diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_admin_freeze.py b/queue_services/entity-filer/tests/unit/filing_processors/test_admin_freeze.py index 99ffd3b5ed..3062229129 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_admin_freeze.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_admin_freeze.py @@ -67,7 +67,7 @@ def test_worker_admin_freeze(app, session, mocker): # Check outcome final_filing = Filing.find_by_id(filing_id) - assert business.admin_freeze == True + assert business.admin_freeze is True assert business.state_filing_id is None assert business.dissolution_date is None assert filing_json["filing"]["adminFreeze"]["details"] == final_filing.order_details diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_annual_report.py b/queue_services/entity-filer/tests/unit/filing_processors/test_annual_report.py index b4c6929d2a..c308c7629d 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_annual_report.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_annual_report.py @@ -37,7 +37,6 @@ def test_process_ar_filing(app, session): # setup business = create_business(identifier, "CP") - business_id = business.id now = datetime.date(2020, 9, 17) ar_date = datetime.date(2020, 8, 5) agm_date = datetime.date(2020, 7, 1) @@ -51,8 +50,6 @@ def test_process_ar_filing(app, session): # TEST with freeze_time(now): filing = create_filing(payment_id, ar, business.id) - filing_id = filing.id - filing_msg = FilingMessage(filing_identifier=filing_id) annual_report.process(business, filing.filing_json["filing"], filing_meta=filing_meta) # check it out diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_dissolution.py b/queue_services/entity-filer/tests/unit/filing_processors/test_dissolution.py index 2088a5e948..4d9004cf97 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_dissolution.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_dissolution.py @@ -85,7 +85,6 @@ def test_dissolution(app, session, legal_type, identifier, dissolution_type): legal_entity_id=business.id, ) party_role.save() - curr_roles = len(business.entity_roles.all()) business.dissolution_date = None business_id = business.id @@ -104,7 +103,6 @@ def test_dissolution(app, session, legal_type, identifier, dissolution_type): assert business.state == LegalEntity.State.HISTORICAL assert business.state_filing_id == filing.id assert len(business.entity_roles.all()) == 2 - entity_roles = filing.filing_entity_roles.all() assert len(filing.filing_entity_roles.all()) == 2 custodial_office = ( @@ -187,7 +185,6 @@ def test_administrative_dissolution(app, session, legal_type, identifier, dissol legal_entity_id=business.id, ) party_role.save() - curr_roles = len(business.entity_roles.all()) business.dissolution_date = None business_id = business.id diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_incorporation_filing.py b/queue_services/entity-filer/tests/unit/filing_processors/test_incorporation_filing.py index f2310be71a..6a9feb7003 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_incorporation_filing.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_incorporation_filing.py @@ -62,7 +62,9 @@ def test_incorporation_filing_process_with_nr(app, session, legal_type, filing, """Assert that the incorporation object is correctly populated to model objects.""" # setup with nested_session(session): - with patch.object(legal_entity_info, "get_next_corp_num", return_value=next_corp_num) as mock_get_next_corp_num: + with patch.object( + legal_entity_info, "get_next_corp_num", return_value=next_corp_num + ) as mock_get_next_corp_num: # noqa F841 identifier = "NR 1234567" filing["filing"]["incorporationApplication"]["nameRequest"]["nrNumber"] = identifier filing["filing"]["incorporationApplication"]["nameRequest"]["legalType"] = legal_type @@ -109,7 +111,7 @@ def test_incorporation_filing_process_with_nr(app, session, legal_type, filing, # assert len(documents) == 2 # for document in documents: # if document.type == DocumentType.COOP_RULES.value: - # original_rules_key = filing['filing']['incorporationApplication']['cooperative']['rulesFileKey'] + # original_rules_key = filing['filing']['incorporationApplication']['cooperative']['rulesFileKey'] # noqa E501; line too long # assert document.file_key == original_rules_key # assert MinioService.get_file(document.file_key) # elif document.type == DocumentType.COOP_MEMORANDUM.value: diff --git a/queue_services/entity-filer/tests/unit/filing_processors/test_put_back_on.py b/queue_services/entity-filer/tests/unit/filing_processors/test_put_back_on.py index 2948fbe5d6..78b9e387be 100644 --- a/queue_services/entity-filer/tests/unit/filing_processors/test_put_back_on.py +++ b/queue_services/entity-filer/tests/unit/filing_processors/test_put_back_on.py @@ -36,8 +36,6 @@ def test_worker_put_back_on(app, session): payment_id = str(random.SystemRandom().getrandbits(0x58)) filing = create_filing(payment_id, filing_json, business_id=business.id) - filing_msg = {"filing": {"id": filing.id}} - filing_meta = FilingMeta() filing = create_filing("123", filing_json) diff --git a/queue_services/entity-filer/tests/unit/worker/test_conversion.py b/queue_services/entity-filer/tests/unit/worker/test_conversion.py index 9e44b72f28..6f7903b5ef 100644 --- a/queue_services/entity-filer/tests/unit/worker/test_conversion.py +++ b/queue_services/entity-filer/tests/unit/worker/test_conversion.py @@ -120,7 +120,6 @@ def test_conversion( def test_worker_proprietor_new_address(app, session, mocker): """Assert the worker process the party new address correctly.""" - identifier = "FM1234567" party = create_entity_person(SP_CONVERSION["filing"]["conversion"]["parties"][0]) party_id = party.id diff --git a/queue_services/entity-filer/tests/unit/worker/test_incorporation.py b/queue_services/entity-filer/tests/unit/worker/test_incorporation.py index 4ff38e6f2c..82b34d75ba 100644 --- a/queue_services/entity-filer/tests/unit/worker/test_incorporation.py +++ b/queue_services/entity-filer/tests/unit/worker/test_incorporation.py @@ -25,7 +25,7 @@ # # from entity_queue_common.messages import get_data_from_msg # from entity_queue_common.service_utils import subscribe_to_queue -from business_model import EntityRole, Filing, LegalEntity, RegistrationBootstrap +from business_model import EntityRole, Filing, LegalEntity from flask import current_app # from legal_api.services import RegistrationBootstrapService