Skip to content

Commit

Permalink
Fix linting issues entity_filer
Browse files Browse the repository at this point in the history
  • Loading branch information
leodube-aot committed Feb 1, 2024
1 parent bfa7a26 commit 493d264
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand Down
2 changes: 1 addition & 1 deletion queue_services/entity-filer/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = (
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 493d264

Please sign in to comment.