From 7329516db163fabcaaa29669a265ffba682e69bf Mon Sep 17 00:00:00 2001 From: leodube-aot Date: Tue, 30 Jan 2024 10:55:50 -0800 Subject: [PATCH] Fix pylint errors on queue-services --- .../src/entity_auth/services/gcp_queue.py | 2 +- .../src/entity_bn/services/gcp_queue.py | 2 +- .../src/entity_emailer/services/gcp_queue.py | 2 +- .../entity-emailer/tests/unit/__init__.py | 2 +- .../src/entity_filer/common/enum.py | 2 ++ .../filing_processors/admin_freeze.py | 2 +- .../amalgamation_application.py | 2 +- .../filing_processors/change_of_directors.py | 4 ++-- .../filing_processors/change_of_registration.py | 1 - .../filing_processors/conversion.py | 17 +++++++++++++---- .../filing_components/correction.py | 3 ++- .../filing_components/legal_entity_info.py | 6 ++++-- .../filing_processors/incorporation_filing.py | 2 +- .../filing_processors/put_back_on.py | 2 +- .../filing_processors/transition.py | 2 +- .../src/entity_filer/services/gcp_queue.py | 2 +- .../src/entity_pay/services/gcp_queue.py | 2 +- 17 files changed, 34 insertions(+), 21 deletions(-) diff --git a/queue_services/entity-auth/src/entity_auth/services/gcp_queue.py b/queue_services/entity-auth/src/entity_auth/services/gcp_queue.py index 8da75eaa82..f4f472eaba 100644 --- a/queue_services/entity-auth/src/entity_auth/services/gcp_queue.py +++ b/queue_services/entity-auth/src/entity_auth/services/gcp_queue.py @@ -62,7 +62,7 @@ def __init__(self, app: Flask = None): self._publisher = None if app: - self.app_init(app) + self.init_app(app) def init_app(self, app: Flask): self.gcp_auth_key = app.config.get("GCP_AUTH_KEY") diff --git a/queue_services/entity-bn/src/entity_bn/services/gcp_queue.py b/queue_services/entity-bn/src/entity_bn/services/gcp_queue.py index 8da75eaa82..f4f472eaba 100644 --- a/queue_services/entity-bn/src/entity_bn/services/gcp_queue.py +++ b/queue_services/entity-bn/src/entity_bn/services/gcp_queue.py @@ -62,7 +62,7 @@ def __init__(self, app: Flask = None): self._publisher = None if app: - self.app_init(app) + self.init_app(app) def init_app(self, app: Flask): self.gcp_auth_key = app.config.get("GCP_AUTH_KEY") diff --git a/queue_services/entity-emailer/src/entity_emailer/services/gcp_queue.py b/queue_services/entity-emailer/src/entity_emailer/services/gcp_queue.py index a9ed3b505f..9d2ebb3b6f 100644 --- a/queue_services/entity-emailer/src/entity_emailer/services/gcp_queue.py +++ b/queue_services/entity-emailer/src/entity_emailer/services/gcp_queue.py @@ -62,7 +62,7 @@ def __init__(self, app: Flask = None): self._publisher = None if app: - self.app_init(app) + self.init_app(app) def init_app(self, app: Flask): self.gcp_auth_key = app.config.get("GCP_AUTH_KEY") diff --git a/queue_services/entity-emailer/tests/unit/__init__.py b/queue_services/entity-emailer/tests/unit/__init__.py index 2922681c1a..d0f31347b0 100644 --- a/queue_services/entity-emailer/tests/unit/__init__.py +++ b/queue_services/entity-emailer/tests/unit/__init__.py @@ -591,7 +591,7 @@ def prep_cp_special_resolution_correction_upload_memorandum_filing( del filing_template["filing"]["correction"]["resolution"] filing_template["filing"]["correction"]["memorandumFileKey"] = "28f73dc4-8e7c-4c89-bef6-a81dff909ca6.pdf" filing_template["filing"]["correction"]["memorandumFileName"] = "test.pdf" - filing = create_filing(token=payment_id, filing_json=filing_template, business_id=business.id) + filing = create_filing(token=payment_id, filing_json=filing_template, legal_entity_id=business.id) filing.payment_completion_date = filing.filing_date # Triggered from the filer. filing._meta_data = {"correction": {"uploadNewMemorandum": True}} diff --git a/queue_services/entity-filer/src/entity_filer/common/enum.py b/queue_services/entity-filer/src/entity_filer/common/enum.py index 051a27edd8..d427937bbc 100644 --- a/queue_services/entity-filer/src/entity_filer/common/enum.py +++ b/queue_services/entity-filer/src/entity_filer/common/enum.py @@ -11,6 +11,7 @@ class BaseMeta(EnumMeta): def __contains__(self, other): """Return True if 'in' the Enum.""" try: + # pylint: disable-next=no-value-for-parameter self(other) except ValueError: return False @@ -37,6 +38,7 @@ def get_enum_by_name(cls, value: str) -> Optional[str]: return enum_value return None + # pylint: disable-next=no-self-argument def _generate_next_value_(name, start, count, last_values): """Return the name of the key.""" return name diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/admin_freeze.py b/queue_services/entity-filer/src/entity_filer/filing_processors/admin_freeze.py index bda4bb00b5..7511c4ac80 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/admin_freeze.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/admin_freeze.py @@ -17,7 +17,7 @@ import dpath -# from entity_filer.exceptions import DefaultException, logger +from entity_filer.exceptions import DefaultException, logger from business_model import LegalEntity, Filing from entity_filer.filing_meta import FilingMeta diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/amalgamation_application.py b/queue_services/entity-filer/src/entity_filer/filing_processors/amalgamation_application.py index e276a12dac..f5c0c6ec66 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/amalgamation_application.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/amalgamation_application.py @@ -19,7 +19,7 @@ import sentry_sdk -# from entity_filer.exceptions import DefaultException +from entity_filer.exceptions import DefaultException from business_model import db, AmalgamatingBusiness, Amalgamation, LegalEntity, Document, Filing, RegistrationBootstrap # from legal_api.services.bootstrap import AccountService diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_directors.py b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_directors.py index fe3973bb17..d3bc839a30 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_directors.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_directors.py @@ -15,7 +15,7 @@ from datetime import datetime from typing import Dict -# from entity_filer.exceptions import DefaultException, logger +from entity_filer.exceptions import DefaultException, logger from business_model import LegalEntity, PartyRole from entity_filer.filing_meta import FilingMeta @@ -67,7 +67,7 @@ def process(business: LegalEntity, filing: Dict, filing_meta: FilingMeta): # py if "appointed" in new_director["actions"]: # add new diretor party role to the business - party = merge_party(business_id=business.id, party_info=new_director) + party = merge_party(legal_entity_id=business.id, party_info=new_director) role = { "roleType": "Director", "appointmentDate": new_director.get("appointmentDate"), diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_registration.py b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_registration.py index bd8494758f..1d07c98aee 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_registration.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/change_of_registration.py @@ -54,7 +54,6 @@ def process( ) case _: # LegalEntity.EntityTypes.SOLE_PROP: # legal_entity might be a proprietor? update_proprietor_change( - legal_entity=legal_entity, filing_type="changeOfRegistration", change_filing_rec=change_filing_rec, change_filing=change_filing, 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 897c5d57f9..8e786ab0ae 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 @@ -23,6 +23,7 @@ """ # pylint: disable=superfluous-parens; as pylance requires it from contextlib import suppress +from http import HTTPStatus from typing import Dict import dpath @@ -58,7 +59,9 @@ def process( # Extract the filing information for incorporation filing_meta.conversion = {} if not (conversion_filing := filing.get("filing", {}).get("conversion")): - raise BusinessException(f"CONVL legal_filing:conversion missing from {filing_rec.id}") + raise BusinessException( + error=f"CONVL legal_filing:conversion missing from {filing_rec.id}", + status_code=HTTPStatus.BAD_REQUEST) # 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 [ @@ -75,9 +78,13 @@ def process( def _process_corps_conversion(legal_entity, conversion_filing, filing, filing_rec): if legal_entity: - raise BusinessException(f"Business Already Exist: CONVL legal_filing:conversion {filing_rec.id}") + raise BusinessException( + error=f"Business Already Exist: CONVL legal_filing:conversion {filing_rec.id}", + status_code=HTTPStatus.FORBIDDEN) if not (corp_num := filing.get("filing", {}).get("business", {}).get("identifier")): - raise BusinessException(f"conversion {filing_rec.id} missing the legal_entity identifier.") + raise BusinessException( + error=f"conversion {filing_rec.id} missing the legal_entity identifier.", + status_code=HTTPStatus.BAD_REQUEST) # Initial insert of the legal_entity record legal_entity_info_obj = conversion_filing.get("nameRequest") if not ( @@ -85,7 +92,9 @@ def _process_corps_conversion(legal_entity, conversion_filing, filing, filing_re corp_num, LegalEntity(), legal_entity_info_obj, filing_rec ) ): - raise BusinessException(f"CONVL conversion {filing_rec.id}, Unable to create legal_entity.") + raise BusinessException( + error=f"CONVL conversion {filing_rec.id}, Unable to create legal_entity.", + status_code=HTTPStatus.UNPROCESSABLE_ENTITY) if offices := conversion_filing.get("offices"): update_offices(legal_entity, offices) if parties := conversion_filing.get("parties"): diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/correction.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/correction.py index 841c395f59..75562f2335 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/correction.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/correction.py @@ -26,6 +26,7 @@ create_role, filings, legal_entity_info, + merge_party, resolutions, rules_and_memorandum, shares, @@ -215,7 +216,7 @@ def _update_party(party_info): def _create_party_info(business, correction_filing_rec, party_info): - party = merge_party(business_id=business.id, party_info=party_info, create=False) + party = merge_party(legal_entity_id=business.id, party_info=party_info, create=False) for role_type in party_info.get("roles"): role_str = role_type.get("roleType", "").lower() role = { diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/legal_entity_info.py b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/legal_entity_info.py index 9d69169370..bf735dfd79 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/legal_entity_info.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/filing_components/legal_entity_info.py @@ -92,8 +92,10 @@ def update_naics_info(legal_entity: LegalEntity, naics: Dict): # TODO update NAICS info legal_entity.naics_code = naics.get("naicsCode") if legal_entity.naics_code: - naics_structure = NaicsService.find_by_code(legal_entity.naics_code) - legal_entity.naics_key = naics_structure["naicsKey"] + # TODO: Uncomment next 2 lines when find_by_code implemented and delete "pass" + # naics_structure = NaicsService.find_by_code(legal_entity.naics_code) + # legal_entity.naics_key = naics_structure["naicsKey"] + pass else: legal_entity.naics_code = None legal_entity.naics_key = None 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 310e093411..8a7df6bea2 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 @@ -19,7 +19,7 @@ import sentry_sdk -# from entity_filer.exceptions import DefaultException +from entity_filer.exceptions import DefaultException from business_model import LegalEntity, Document, Filing, RegistrationBootstrap from business_model.models.document import DocumentType diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/put_back_on.py b/queue_services/entity-filer/src/entity_filer/filing_processors/put_back_on.py index ff464e54a9..6c6dac49a5 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/put_back_on.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/put_back_on.py @@ -18,7 +18,7 @@ import dpath -# from entity_filer.exceptions import DefaultException, logger +from entity_filer.exceptions import DefaultException, logger from business_model import LegalEntity, Filing from entity_filer.filing_meta import FilingMeta diff --git a/queue_services/entity-filer/src/entity_filer/filing_processors/transition.py b/queue_services/entity-filer/src/entity_filer/filing_processors/transition.py index 9cc470d060..03bea44907 100644 --- a/queue_services/entity-filer/src/entity_filer/filing_processors/transition.py +++ b/queue_services/entity-filer/src/entity_filer/filing_processors/transition.py @@ -14,7 +14,7 @@ """File processing rules and actions for the transition of a business.""" from typing import Dict -# from entity_filer.exceptions import DefaultException +from entity_filer.exceptions import DefaultException from business_model import LegalEntity, Filing from entity_filer.filing_meta import FilingMeta diff --git a/queue_services/entity-filer/src/entity_filer/services/gcp_queue.py b/queue_services/entity-filer/src/entity_filer/services/gcp_queue.py index 8da75eaa82..f4f472eaba 100644 --- a/queue_services/entity-filer/src/entity_filer/services/gcp_queue.py +++ b/queue_services/entity-filer/src/entity_filer/services/gcp_queue.py @@ -62,7 +62,7 @@ def __init__(self, app: Flask = None): self._publisher = None if app: - self.app_init(app) + self.init_app(app) def init_app(self, app: Flask): self.gcp_auth_key = app.config.get("GCP_AUTH_KEY") diff --git a/queue_services/entity-pay/src/entity_pay/services/gcp_queue.py b/queue_services/entity-pay/src/entity_pay/services/gcp_queue.py index 8da75eaa82..f4f472eaba 100644 --- a/queue_services/entity-pay/src/entity_pay/services/gcp_queue.py +++ b/queue_services/entity-pay/src/entity_pay/services/gcp_queue.py @@ -62,7 +62,7 @@ def __init__(self, app: Flask = None): self._publisher = None if app: - self.app_init(app) + self.init_app(app) def init_app(self, app: Flask): self.gcp_auth_key = app.config.get("GCP_AUTH_KEY")