From 56f77e0a7719428a96fa756a0d775bddc5fc2521 Mon Sep 17 00:00:00 2001 From: Victor Shia Date: Thu, 26 Sep 2024 10:47:48 -0700 Subject: [PATCH] chore: Replace conint and constr with new types (#442) * chore: Replace conint and constr with new types * Fix ruff issues --------- Co-authored-by: Victor Shia <401047+vshia@users.noreply.github.com> --- .../src/functions/generate_treasury_report.py | 2 + python/src/schemas/custom_types.py | 132 +++++- python/src/schemas/schema_V2024_04_01.py | 257 ++++++------ python/src/schemas/schema_V2024_05_24.py | 375 ++++++++---------- python/tests/conftest.py | 1 + 5 files changed, 406 insertions(+), 361 deletions(-) diff --git a/python/src/functions/generate_treasury_report.py b/python/src/functions/generate_treasury_report.py index 6b974205..2cb5775b 100644 --- a/python/src/functions/generate_treasury_report.py +++ b/python/src/functions/generate_treasury_report.py @@ -255,6 +255,7 @@ def process_event(payload: ProjectLambdaPayload, logger: structlog.stdlib.BoundL file=json_file, ) + def download_output_file( s3_client: S3Client, output_file: IO[bytes], @@ -299,6 +300,7 @@ def download_output_file( highest_row_num = OUTPUT_STARTING_ROW - 1 return highest_row_num + def get_existing_output_metadata( s3_client, organization: OrganizationObj, diff --git a/python/src/schemas/custom_types.py b/python/src/schemas/custom_types.py index 7b80bb5c..57651e28 100644 --- a/python/src/schemas/custom_types.py +++ b/python/src/schemas/custom_types.py @@ -1,54 +1,144 @@ from typing_extensions import Annotated -from pydantic import BaseModel, Field, PlainSerializer +from pydantic import Field, StringConstraints, PlainSerializer from decimal import Decimal CustomDecimal_16Digits = Annotated[ - Decimal, Field( - max_digits=16, - decimal_places=2 - ), PlainSerializer( + Decimal, + Field(max_digits=16, decimal_places=2), + PlainSerializer( lambda x: f"{float(x):.2f}", return_type=str, ), ] CustomDecimal_15Digits = Annotated[ - Decimal, Field( - max_digits=15, - decimal_places=2 - ), PlainSerializer( + Decimal, + Field(max_digits=15, decimal_places=2), + PlainSerializer( lambda x: f"{float(x):.2f}", return_type=str, ), ] CustomDecimal_13Digits = Annotated[ - Decimal, Field( - max_digits=13, - decimal_places=2 - ), PlainSerializer( + Decimal, + Field(max_digits=13, decimal_places=2), + PlainSerializer( lambda x: f"{float(x):.2f}", return_type=str, ), ] CustomDecimal_12Digits = Annotated[ - Decimal, Field( - max_digits=12, - decimal_places=2 - ), PlainSerializer( + Decimal, + Field(max_digits=12, decimal_places=2), + PlainSerializer( lambda x: f"{float(x):.2f}", return_type=str, ), ] CustomDecimal_7Digits = Annotated[ - Decimal, Field( - max_digits=7, - decimal_places=2 - ), PlainSerializer( + Decimal, + Field(max_digits=7, decimal_places=2), + PlainSerializer( lambda x: f"{float(x):.2f}", return_type=str, ), ] + +CustomInt_GE1 = Annotated[int, Field(ge=1)] +CustomInt_GE0_LELARGE = Annotated[int, Field(ge=0, le=999999999)] +CustomInt_GE0_LELARGE2 = Annotated[int, Field(ge=0, le=9999999999)] +CustomInt_GE0_LELARGE3 = Annotated[int, Field(ge=0, le=99999999999)] +CustomInt_GE0_LELARGE4 = Annotated[int, Field(ge=0, le=999999999999)] + +CustomStr_MIN1 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + ), +] + +CustomStr_MIN1_MAX100 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=100, + ), +] + +CustomStr_MIN1_MAX10 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=10, + ), +] + +CustomStr_MIN1_MAX20 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=20, + ), +] + +CustomStr_MIN12_MAX12 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=12, + max_length=12, + ), +] + +CustomStr_MIN9_MAX9 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=9, + max_length=9, + ), +] + +CustomStr_MIN1_MAX3000 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=3000, + ), +] + +CustomStr_MIN1_MAX5 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=5, + ), +] + +CustomStr_MIN1_MAX40 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=40, + ), +] + +CustomStr_MIN1_MAX80 = Annotated[ + str, + StringConstraints( + strip_whitespace=True, + min_length=1, + max_length=80, + ), +] diff --git a/python/src/schemas/schema_V2024_04_01.py b/python/src/schemas/schema_V2024_04_01.py index 44c585fa..428d9c2e 100644 --- a/python/src/schemas/schema_V2024_04_01.py +++ b/python/src/schemas/schema_V2024_04_01.py @@ -7,8 +7,6 @@ ConfigDict, Field, ValidationInfo, - conint, - constr, field_serializer, field_validator, ) @@ -18,6 +16,21 @@ CustomDecimal_7Digits, CustomDecimal_12Digits, CustomDecimal_13Digits, + CustomInt_GE1, + CustomInt_GE0_LELARGE, + CustomInt_GE0_LELARGE2, + CustomInt_GE0_LELARGE3, + CustomInt_GE0_LELARGE4, + CustomStr_MIN1, + CustomStr_MIN1_MAX100, + CustomStr_MIN1_MAX10, + CustomStr_MIN1_MAX20, + CustomStr_MIN12_MAX12, + CustomStr_MIN9_MAX9, + CustomStr_MIN1_MAX3000, + CustomStr_MIN1_MAX5, + CustomStr_MIN1_MAX40, + CustomStr_MIN1_MAX80, ) @@ -111,27 +124,21 @@ class ProjectInvestmentType(str, Enum): class BaseProjectRow(BaseModel): model_config = ConfigDict(coerce_numbers_to_str=True, loc_by_alias=False) - row_num: conint(ge=1) = Field( + row_num: CustomInt_GE1 = Field( default=1, serialization_alias="Row Number", json_schema_extra={"column": "NONE"}, ) - Project_Name__c: constr(strip_whitespace=True, min_length=1, max_length=100) = ( - Field( - ..., serialization_alias="Project Name", json_schema_extra={"column": "C"} - ) + Project_Name__c: CustomStr_MIN1_MAX100 = Field( + ..., serialization_alias="Project Name", json_schema_extra={"column": "C"} ) - Identification_Number__c: constr( - strip_whitespace=True, min_length=1, max_length=20 - ) = Field( + Identification_Number__c: CustomStr_MIN1_MAX20 = Field( ..., serialization_alias="Identification Number", json_schema_extra={"column": "D"}, ) - Project_Description__c: constr( - strip_whitespace=True, min_length=1, max_length=3000 - ) = Field( + Project_Description__c: CustomStr_MIN1_MAX3000 = Field( ..., serialization_alias="Project Description", json_schema_extra={"column": "E"}, @@ -141,19 +148,15 @@ class BaseProjectRow(BaseModel): serialization_alias="Capital Asset Owenership Type", json_schema_extra={"column": "F"}, ) - Total_CPF_Funding_for_Project__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Total CPF Funding for Project", - json_schema_extra={"column": "G"}, - ) + Total_CPF_Funding_for_Project__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Total CPF Funding for Project", + json_schema_extra={"column": "G"}, ) - Total_from_all_funding_sources__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Total From all Funding Sources", - json_schema_extra={"column": "H"}, - ) + Total_from_all_funding_sources__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Total From all Funding Sources", + json_schema_extra={"column": "H"}, ) Narrative_Description__c: Optional[str] = Field( default=None, @@ -181,10 +184,8 @@ class BaseProjectRow(BaseModel): serialization_alias="Cumulative Expenditure", json_schema_extra={"column": "M"}, ) - Cost_Overview__c: constr(strip_whitespace=True, min_length=1, max_length=3000) = ( - Field( - ..., serialization_alias="Cost Overview", json_schema_extra={"column": "N"} - ) + Cost_Overview__c: CustomStr_MIN1_MAX3000 = Field( + ..., serialization_alias="Cost Overview", json_schema_extra={"column": "N"} ) Project_Status__c: ProjectStatusType = Field( ..., serialization_alias="Project Status", json_schema_extra={"column": "O"} @@ -260,17 +261,17 @@ class BaseProjectRow(BaseModel): serialization_alias="Davis Bacon Certification?", json_schema_extra={"column": "AC"}, ) - Number_of_Direct_Employees__c: Optional[conint(ge=0, le=99999999999)] = Field( + Number_of_Direct_Employees__c: Optional[CustomInt_GE0_LELARGE3] = Field( default=None, serialization_alias="Number of Direct Employees", json_schema_extra={"column": "AD"}, ) - Number_of_Contractor_Employees__c: Optional[conint(ge=0, le=9999999999)] = Field( + Number_of_Contractor_Employees__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Number of Contractor Employees", json_schema_extra={"column": "AE"}, ) - Number_of_3rd_Party_Employees__c: Optional[conint(ge=0, le=999999999999)] = Field( + Number_of_3rd_Party_Employees__c: Optional[CustomInt_GE0_LELARGE4] = Field( default=None, serialization_alias="Number of 3rd Party Employees", json_schema_extra={"column": "AF"}, @@ -411,57 +412,55 @@ class Project1ARow(BaseProjectRow): max_length=3000, json_schema_extra={"column": "AU"}, ) - Total_Miles_Planned__c: conint(ge=0, le=999999999) = Field( + Total_Miles_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="Total Miles of Fiber Deployed (Planned)", json_schema_extra={"column": "AV"}, ) - Total_Miles_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Total_Miles_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="Total Miles of Fiber Deployed (Actual)", json_schema_extra={"column": "AW"}, ) - Locations_Served_Planned__c: conint(ge=0, le=999999999) = Field( + Locations_Served_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="A) Total Number of Locations Served (Planned)", json_schema_extra={"column": "AX"}, ) - Locations_Served_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Locations_Served_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="A) Total Number of Locations Served (Actual)", json_schema_extra={"column": "AY"}, ) - X25_3_Mbps_or_below_Planned__c: conint(ge=0, le=999999999) = Field( + X25_3_Mbps_or_below_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="B) Less than 25/3 Mbps (Planned)", json_schema_extra={"column": "AZ"}, ) - X25_3_Mbps_and_100_20_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + X25_3_Mbps_and_100_20_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="C) 25/3 Mbps and 100/20 Mbps (Planned)", json_schema_extra={"column": "BA"}, ) - Minimum_100_100_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + Minimum_100_100_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="D) Minimum 100/100 Mbps (Planned) ", json_schema_extra={"column": "BB"}, ) - Minimum_100_100_Mbps_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Minimum_100_100_Mbps_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="D) Minimum 100/100 Mbps (Actual) ", json_schema_extra={"column": "BC"}, ) - X100_20_Mbps_to_100_100_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + X100_20_Mbps_to_100_100_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Planned)", json_schema_extra={"column": "BD"}, ) - X100_20_Mbps_to_100_100_Mbps_Actual__c: Optional[conint(ge=0, le=999999999)] = ( - Field( - default=None, - serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Actual)", - json_schema_extra={"column": "BE"}, - ) + X100_20_Mbps_to_100_100_Mbps_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( + default=None, + serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Actual)", + json_schema_extra={"column": "BE"}, ) Explanation_of_Discrepancy__c: Optional[str] = Field( default=None, @@ -469,42 +468,42 @@ class Project1ARow(BaseProjectRow): max_length=3000, json_schema_extra={"column": "BF"}, ) - Number_of_Locations_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_Locations_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="F) Total Number of Locations Served by Type - Residential (Planned)", json_schema_extra={"column": "BG"}, ) - Number_of_Locations_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_Locations_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="F) Total Number of Locations Served by Type - Residential (Actual)", json_schema_extra={"column": "BH"}, ) - Housing_Units_Planned__c: conint(ge=0, le=999999999) = Field( + Housing_Units_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="G) Total Housing Units (Planned)", json_schema_extra={"column": "BI"}, ) - Housing_Units_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Housing_Units_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="G) Total Housing Units (Actual)", json_schema_extra={"column": "BJ"}, ) - Number_of_Bus_Locations_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_Bus_Locations_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="H) Total Number of Locations Served by Type - Business (Planned)", json_schema_extra={"column": "BK"}, ) - Number_of_Bus_Locations_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_Bus_Locations_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="H) Total Number of Locations Served by Type - Business (Actual)", json_schema_extra={"column": "BL"}, ) - Number_of_CAI_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_CAI_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="I) Total Number of Locations Served by Type - Community Anchor Institution (Planned)", json_schema_extra={"column": "BM"}, ) - Number_of_CAI_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_CAI_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="I) Total Number of Locations Served by Type - Community Anchor Institution (Actual)", json_schema_extra={"column": "BN"}, @@ -543,12 +542,10 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class AddressFields(BaseModel): - Street_1_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=40) = ( - Field( - ..., - serialization_alias="Street 1 (Planned)", - json_schema_extra={"column": "BQ"}, - ) + Street_1_Planned__c: CustomStr_MIN1_MAX40 = Field( + ..., + serialization_alias="Street 1 (Planned)", + json_schema_extra={"column": "BQ"}, ) Street_2_Planned__c: Optional[str] = Field( default=None, @@ -573,7 +570,7 @@ class AddressFields(BaseModel): max_length=40, json_schema_extra={"column": "BU"}, ) - City_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=40) = Field( + City_Planned__c: CustomStr_MIN1_MAX40 = Field( ..., serialization_alias="City (Planned)", json_schema_extra={"column": "BV"} ) City_Actual__c: Optional[str] = Field( @@ -590,12 +587,10 @@ class AddressFields(BaseModel): serialization_alias="State (Actual)", json_schema_extra={"column": "BY"}, ) - Zip_Code_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=5) = ( - Field( - ..., - serialization_alias="Zip Code (Planned)", - json_schema_extra={"column": "BZ"}, - ) + Zip_Code_Planned__c: CustomStr_MIN1_MAX5 = Field( + ..., + serialization_alias="Zip Code (Planned)", + json_schema_extra={"column": "BZ"}, ) Zip_Code_Actual__c: Optional[str] = Field( default=None, @@ -617,30 +612,28 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class Project1BRow(BaseProjectRow, AddressFields): - Laptops_Planned__c: conint(ge=0, le=9999999999) = Field( + Laptops_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Laptops (Planned)", json_schema_extra={"column": "CB"} ) - Laptops_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Laptops_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Laptops (Actual)", json_schema_extra={"column": "CC"}, ) - Laptops_Expenditures_Planned__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Laptops Expenditure (Planned)", - json_schema_extra={"column": "CD"}, - ) + Laptops_Expenditures_Planned__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Laptops Expenditure (Planned)", + json_schema_extra={"column": "CD"}, ) Laptops_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Laptops Expenditure (Actual)", json_schema_extra={"column": "CE"}, ) - Tablets_Planned__c: conint(ge=0, le=9999999999) = Field( + Tablets_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Tablets (Planned)", json_schema_extra={"column": "CF"} ) - Tablets_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Tablets_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Tablets (Actual)", json_schema_extra={"column": "CG"}, @@ -655,12 +648,12 @@ class Project1BRow(BaseProjectRow, AddressFields): serialization_alias="Tablets Expenditure (Actual)", json_schema_extra={"column": "CI"}, ) - Desktop_Computers_Planned__c: conint(ge=0, le=9999999999) = Field( + Desktop_Computers_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Desktop Computers (Planned)", json_schema_extra={"column": "CJ"}, ) - Desktop_Computers_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Desktop_Computers_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Desktop Computers (Actual)", json_schema_extra={"column": "CK"}, @@ -670,43 +663,37 @@ class Project1BRow(BaseProjectRow, AddressFields): serialization_alias="Desktop Computers Expenditure (Planned)", json_schema_extra={"column": "CL"}, ) - Desktop_Computers_Expenditures_Actual__c: Optional[ - CustomDecimal_13Digits - ] = Field( + Desktop_Computers_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Desktop Computers Expenditure (Actual)", json_schema_extra={"column": "CM"}, ) - Public_WiFi_Planned__c: conint(ge=0, le=9999999999) = Field( + Public_WiFi_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Public WiFi (Planned)", json_schema_extra={"column": "CN"}, ) - Public_WiFi_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Public_WiFi_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Public WiFi (Actual)", json_schema_extra={"column": "CO"}, ) - Public_WiFi_Expenditures_Planned__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Public Wifi Expenditures (Planned)", - json_schema_extra={"column": "CP"}, - ) + Public_WiFi_Expenditures_Planned__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Public Wifi Expenditures (Planned)", + json_schema_extra={"column": "CP"}, ) - Public_WiFi_Expenditures_Actual__c: Optional[ - CustomDecimal_13Digits - ] = Field( + Public_WiFi_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Public Wifi Expenditures (Actual)", json_schema_extra={"column": "CQ"}, ) - Other_Devices_Planned__c: conint(ge=0, le=9999999999) = Field( + Other_Devices_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Other Devices (Planned)", json_schema_extra={"column": "CR"}, ) - Other_Devices_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Devices_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Devices (Actual)", json_schema_extra={"column": "CS"}, @@ -727,19 +714,17 @@ class Project1BRow(BaseProjectRow, AddressFields): max_length=3000, json_schema_extra={"column": "CV"}, ) - Number_of_Users_Planned__c: conint(ge=0, le=9999999999) = Field( + Number_of_Users_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Number of Users (Planned)", json_schema_extra={"column": "CW"}, ) - Number_of_Users_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Number_of_Users_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Number of Users (Actual)", json_schema_extra={"column": "CX"}, ) - Brief_Narrative_Planned__c: constr( - strip_whitespace=True, min_length=1, max_length=3000 - ) = Field( + Brief_Narrative_Planned__c: CustomStr_MIN1_MAX3000 = Field( ..., serialization_alias="Brief Narrative (Planned)", json_schema_extra={"column": "CY"}, @@ -790,52 +775,52 @@ class Project1CRow(BaseProjectRow, AddressFields): max_length=32000, json_schema_extra={"column": "DC"}, ) - Classrooms_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Classrooms_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Classrooms (Planned)", json_schema_extra={"column": "DD"}, ) - Classrooms_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Classrooms_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Classrooms (Actual)", json_schema_extra={"column": "DE"}, ) - Computer_labs_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Computer_labs_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Computer labs (Planned)", json_schema_extra={"column": "DF"}, ) - Computer_labs_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Computer_labs_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Computer labs (Actual)", json_schema_extra={"column": "DG"}, ) - Multi_purpose_Spaces_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Multi_purpose_Spaces_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Multi-purpose Spaces (Planned)", json_schema_extra={"column": "DH"}, ) - Multi_purpose_Spaces_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Multi_purpose_Spaces_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Multi-purpose Spaces (Actual)", json_schema_extra={"column": "DI"}, ) - Telemedicine_Rooms_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Telemedicine_Rooms_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Telemedicine Rooms (Planned)", json_schema_extra={"column": "DJ"}, ) - Telemedicine_Rooms_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Telemedicine_Rooms_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Telemedicine Rooms (Actual)", json_schema_extra={"column": "DK"}, ) - Other_Capital_Assets_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Capital_Assets_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Capital Assets (Planned)", json_schema_extra={"column": "DL"}, ) - Other_Capital_Assets_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Capital_Assets_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Capital Assets (Actual)", json_schema_extra={"column": "DM"}, @@ -846,17 +831,17 @@ class Project1CRow(BaseProjectRow, AddressFields): max_length=3000, json_schema_extra={"column": "DN"}, ) - Total_square_footage_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_square_footage_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total square footage (Planned)", json_schema_extra={"column": "DO"}, ) - Total_square_footage_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_square_footage_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total square footage (Actual)", json_schema_extra={"column": "DP"}, ) - Total_Number_of_Users_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_Number_of_Users_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total Number of Users (Actual)", json_schema_extra={"column": "DQ"}, @@ -884,39 +869,33 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class SubrecipientRow(BaseModel): model_config = ConfigDict(coerce_numbers_to_str=True, loc_by_alias=False) - Name: constr(strip_whitespace=True, min_length=1, max_length=80) = Field( + Name: CustomStr_MIN1_MAX80 = Field( ..., serialization_alias="Subrecipient Name", json_schema_extra={"column": "C"} ) - EIN__c: constr(strip_whitespace=True, min_length=9, max_length=9) = Field( + EIN__c: CustomStr_MIN9_MAX9 = Field( ..., serialization_alias="Subrecipient Tax ID Number (TIN)", json_schema_extra={"column": "D"}, ) - Unique_Entity_Identifier__c: constr( - strip_whitespace=True, min_length=12, max_length=12 - ) = Field( + Unique_Entity_Identifier__c: CustomStr_MIN12_MAX12 = Field( ..., serialization_alias="Unique Entity Identifier (UEI)", json_schema_extra={"column": "E"}, ) - POC_Name__c: constr(strip_whitespace=True, min_length=1, max_length=100) = Field( + POC_Name__c: CustomStr_MIN1_MAX100 = Field( ..., serialization_alias="POC Name", json_schema_extra={"column": "F"} ) - POC_Phone_Number__c: constr(strip_whitespace=True, min_length=1, max_length=10) = ( - Field( - ..., - serialization_alias="POC Phone Number", - json_schema_extra={"column": "G"}, - ) - ) - POC_Email_Address__c: constr(strip_whitespace=True, min_length=1, max_length=80) = ( - Field( - ..., - serialization_alias="POC Email Address", - json_schema_extra={"column": "H"}, - ) - ) - Zip__c: constr(strip_whitespace=True, min_length=1, max_length=5) = Field( + POC_Phone_Number__c: CustomStr_MIN1_MAX10 = Field( + ..., + serialization_alias="POC Phone Number", + json_schema_extra={"column": "G"}, + ) + POC_Email_Address__c: CustomStr_MIN1_MAX80 = Field( + ..., + serialization_alias="POC Email Address", + json_schema_extra={"column": "H"}, + ) + Zip__c: CustomStr_MIN1_MAX5 = Field( ..., serialization_alias="Zip5", json_schema_extra={"column": "I"} ) Zip_4__c: Optional[str] = Field( @@ -925,7 +904,7 @@ class SubrecipientRow(BaseModel): max_length=4, json_schema_extra={"column": "J"}, ) - Address__c: constr(strip_whitespace=True, min_length=1, max_length=40) = Field( + Address__c: CustomStr_MIN1_MAX40 = Field( ..., serialization_alias="Address Line 1", json_schema_extra={"column": "K"} ) Address_2__c: Optional[str] = Field( @@ -940,7 +919,7 @@ class SubrecipientRow(BaseModel): max_length=40, json_schema_extra={"column": "M"}, ) - City__c: constr(strip_whitespace=True, min_length=1, max_length=100) = Field( + City__c: CustomStr_MIN1_MAX100 = Field( ..., serialization_alias="City", json_schema_extra={"column": "N"} ) State_Abbreviated__c: StateAbbreviation = Field( @@ -994,10 +973,10 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class CoverSheetRow(BaseModel): model_config = ConfigDict(loc_by_alias=False) - project_use_code: constr(strip_whitespace=True, min_length=1) = Field( + project_use_code: CustomStr_MIN1 = Field( ..., alias="Project Use Code", json_schema_extra={"column": "A"} ) - project_use_name: constr(strip_whitespace=True, min_length=1) = Field( + project_use_name: CustomStr_MIN1 = Field( ..., alias="Project Use Name", json_schema_extra={"column": "B"} ) diff --git a/python/src/schemas/schema_V2024_05_24.py b/python/src/schemas/schema_V2024_05_24.py index 18c6cea8..bcfdcf4e 100644 --- a/python/src/schemas/schema_V2024_05_24.py +++ b/python/src/schemas/schema_V2024_05_24.py @@ -7,8 +7,6 @@ ConfigDict, Field, ValidationInfo, - conint, - constr, field_serializer, field_validator, ) @@ -19,8 +17,24 @@ CustomDecimal_12Digits, CustomDecimal_13Digits, CustomDecimal_15Digits, + CustomInt_GE1, + CustomInt_GE0_LELARGE, + CustomInt_GE0_LELARGE2, + CustomInt_GE0_LELARGE3, + CustomInt_GE0_LELARGE4, + CustomStr_MIN1, + CustomStr_MIN1_MAX100, + CustomStr_MIN1_MAX10, + CustomStr_MIN1_MAX20, + CustomStr_MIN12_MAX12, + CustomStr_MIN9_MAX9, + CustomStr_MIN1_MAX3000, + CustomStr_MIN1_MAX5, + CustomStr_MIN1_MAX40, + CustomStr_MIN1_MAX80, ) + class StateAbbreviation(str, Enum): AL = "AL" AK = "AK" @@ -129,7 +143,7 @@ def __str__(self): class BaseProjectRow(BaseModel): model_config = ConfigDict(coerce_numbers_to_str=True, loc_by_alias=False) - row_num: conint(ge=1) = Field( + row_num: CustomInt_GE1 = Field( default=1, serialization_alias="Row Number", json_schema_extra={ @@ -139,21 +153,17 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": None, }, ) - Project_Name__c: constr(strip_whitespace=True, min_length=1, max_length=100) = ( - Field( - ..., - serialization_alias="Project Name", - json_schema_extra={ - "column": "C", - "treasury_report_col_1A": "B", - "treasury_report_col_1B": "B", - "treasury_report_col_1C": "B", - }, - ) - ) - Identification_Number__c: constr( - strip_whitespace=True, min_length=1, max_length=20 - ) = Field( + Project_Name__c: CustomStr_MIN1_MAX100 = Field( + ..., + serialization_alias="Project Name", + json_schema_extra={ + "column": "C", + "treasury_report_col_1A": "B", + "treasury_report_col_1B": "B", + "treasury_report_col_1C": "B", + }, + ) + Identification_Number__c: CustomStr_MIN1_MAX20 = Field( ..., serialization_alias="Identification Number", json_schema_extra={ @@ -163,33 +173,27 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "C", }, ) - Subrecipient_UEI__c: constr(strip_whitespace=True, min_length=12, max_length=12) = ( - Field( - ..., - serialization_alias="Subrecipient UEI", - json_schema_extra={ - "column": "E", - "treasury_report_col_1A": "D", - "treasury_report_col_1B": "D", - "treasury_report_col_1C": "D", - }, - ) - ) - Subrecipient_TIN__c: constr(strip_whitespace=True, min_length=9, max_length=9) = ( - Field( - ..., - serialization_alias="Subrecipient TIN", - json_schema_extra={ - "column": "F", - "treasury_report_col_1A": "E", - "treasury_report_col_1B": "E", - "treasury_report_col_1C": "E", - }, - ) - ) - Project_Description__c: constr( - strip_whitespace=True, min_length=1, max_length=3000 - ) = Field( + Subrecipient_UEI__c: CustomStr_MIN12_MAX12 = Field( + ..., + serialization_alias="Subrecipient UEI", + json_schema_extra={ + "column": "E", + "treasury_report_col_1A": "D", + "treasury_report_col_1B": "D", + "treasury_report_col_1C": "D", + }, + ) + Subrecipient_TIN__c: CustomStr_MIN9_MAX9 = Field( + ..., + serialization_alias="Subrecipient TIN", + json_schema_extra={ + "column": "F", + "treasury_report_col_1A": "E", + "treasury_report_col_1B": "E", + "treasury_report_col_1C": "E", + }, + ) + Project_Description__c: CustomStr_MIN1_MAX3000 = Field( ..., serialization_alias="Project Description", json_schema_extra={ @@ -209,29 +213,25 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "G", }, ) - Total_CPF_Funding_for_Project__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Total CPF Funding for Project", - json_schema_extra={ - "column": "I", - "treasury_report_col_1A": "H", - "treasury_report_col_1B": "H", - "treasury_report_col_1C": "H", - }, - ) - ) - Total_from_all_funding_sources__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Total From all Funding Sources", - json_schema_extra={ - "column": "J", - "treasury_report_col_1A": "I", - "treasury_report_col_1B": "I", - "treasury_report_col_1C": "I", - }, - ) + Total_CPF_Funding_for_Project__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Total CPF Funding for Project", + json_schema_extra={ + "column": "I", + "treasury_report_col_1A": "H", + "treasury_report_col_1B": "H", + "treasury_report_col_1C": "H", + }, + ) + Total_from_all_funding_sources__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Total From all Funding Sources", + json_schema_extra={ + "column": "J", + "treasury_report_col_1A": "I", + "treasury_report_col_1B": "I", + "treasury_report_col_1C": "I", + }, ) Narrative_Description__c: Optional[str] = Field( default=None, @@ -247,7 +247,6 @@ class BaseProjectRow(BaseModel): Current_Period_Obligation__c: CustomDecimal_12Digits = Field( ..., serialization_alias="Current Period Obligation", - json_schema_extra={ "column": "L", "treasury_report_col_1A": "K", @@ -285,17 +284,15 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "N", }, ) - Cost_Overview__c: constr(strip_whitespace=True, min_length=1, max_length=3000) = ( - Field( - ..., - serialization_alias="Cost Overview", - json_schema_extra={ - "column": "P", - "treasury_report_col_1A": "O", - "treasury_report_col_1B": "U", - "treasury_report_col_1C": "U", - }, - ) + Cost_Overview__c: CustomStr_MIN1_MAX3000 = Field( + ..., + serialization_alias="Cost Overview", + json_schema_extra={ + "column": "P", + "treasury_report_col_1A": "O", + "treasury_report_col_1B": "U", + "treasury_report_col_1C": "U", + }, ) Project_Status__c: ProjectStatusType = Field( ..., @@ -450,7 +447,7 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "AJ", }, ) - Number_of_Direct_Employees__c: Optional[conint(ge=0, le=99999999999)] = Field( + Number_of_Direct_Employees__c: Optional[CustomInt_GE0_LELARGE3] = Field( default=None, serialization_alias="Number of Direct Employees", json_schema_extra={ @@ -460,7 +457,7 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "AK", }, ) - Number_of_Contractor_Employees__c: Optional[conint(ge=0, le=9999999999)] = Field( + Number_of_Contractor_Employees__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Number of Contractor Employees", json_schema_extra={ @@ -470,7 +467,7 @@ class BaseProjectRow(BaseModel): "treasury_report_col_1C": "AL", }, ) - Number_of_3rd_Party_Employees__c: Optional[conint(ge=0, le=999999999999)] = Field( + Number_of_3rd_Party_Employees__c: Optional[CustomInt_GE0_LELARGE4] = Field( default=None, serialization_alias="Number of 3rd Party Employees", json_schema_extra={ @@ -671,57 +668,55 @@ class Project1ARow(BaseProjectRow): max_length=3000, json_schema_extra={"column": "AW", "treasury_report_col_1A": "AW"}, ) - Total_Miles_Planned__c: conint(ge=0, le=999999999) = Field( + Total_Miles_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="Total Miles of Fiber Deployed (Planned)", json_schema_extra={"column": "AX", "treasury_report_col_1A": "AX"}, ) - Total_Miles_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Total_Miles_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="Total Miles of Fiber Deployed (Actual)", json_schema_extra={"column": "AY", "treasury_report_col_1A": "AY"}, ) - Locations_Served_Planned__c: conint(ge=0, le=999999999) = Field( + Locations_Served_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="A) Total Number of Locations Served (Planned)", json_schema_extra={"column": "AZ", "treasury_report_col_1A": "AZ"}, ) - Locations_Served_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Locations_Served_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="A) Total Number of Locations Served (Actual)", json_schema_extra={"column": "BA", "treasury_report_col_1A": "BA"}, ) - X25_3_Mbps_or_below_Planned__c: conint(ge=0, le=999999999) = Field( + X25_3_Mbps_or_below_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="B) Less than 25/3 Mbps (Planned)", json_schema_extra={"column": "BB", "treasury_report_col_1A": "BB"}, ) - X25_3_Mbps_and_100_20_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + X25_3_Mbps_and_100_20_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="C) 25/3 Mbps and 100/20 Mbps (Planned)", json_schema_extra={"column": "BC", "treasury_report_col_1A": "BC"}, ) - Minimum_100_100_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + Minimum_100_100_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="D) Minimum 100/100 Mbps (Planned) ", json_schema_extra={"column": "BD", "treasury_report_col_1A": "BD"}, ) - Minimum_100_100_Mbps_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Minimum_100_100_Mbps_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="D) Minimum 100/100 Mbps (Actual) ", json_schema_extra={"column": "BE", "treasury_report_col_1A": "BE"}, ) - X100_20_Mbps_to_100_100_Mbps_Planned__c: conint(ge=0, le=999999999) = Field( + X100_20_Mbps_to_100_100_Mbps_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Planned)", json_schema_extra={"column": "BF", "treasury_report_col_1A": "BF"}, ) - X100_20_Mbps_to_100_100_Mbps_Actual__c: Optional[conint(ge=0, le=999999999)] = ( - Field( - default=None, - serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Actual)", - json_schema_extra={"column": "BG", "treasury_report_col_1A": "BG"}, - ) + X100_20_Mbps_to_100_100_Mbps_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( + default=None, + serialization_alias="E) 100/20 Mbps to 100/100 Mbps (Actual)", + json_schema_extra={"column": "BG", "treasury_report_col_1A": "BG"}, ) Explanation_of_Discrepancy__c: Optional[str] = Field( default=None, @@ -729,42 +724,42 @@ class Project1ARow(BaseProjectRow): max_length=3000, json_schema_extra={"column": "BH", "treasury_report_col_1A": "BH"}, ) - Number_of_Locations_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_Locations_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="F) Total Number of Locations Served by Type - Residential (Planned)", json_schema_extra={"column": "BI", "treasury_report_col_1A": "BJ"}, ) - Number_of_Locations_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_Locations_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="F) Total Number of Locations Served by Type - Residential (Actual)", json_schema_extra={"column": "BJ", "treasury_report_col_1A": "BK"}, ) - Housing_Units_Planned__c: conint(ge=0, le=999999999) = Field( + Housing_Units_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="G) Total Housing Units (Planned)", json_schema_extra={"column": "BK", "treasury_report_col_1A": "BL"}, ) - Housing_Units_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Housing_Units_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="G) Total Housing Units (Actual)", json_schema_extra={"column": "BL", "treasury_report_col_1A": "BM"}, ) - Number_of_Bus_Locations_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_Bus_Locations_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="H) Total Number of Locations Served by Type - Business (Planned)", json_schema_extra={"column": "BM", "treasury_report_col_1A": "BN"}, ) - Number_of_Bus_Locations_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_Bus_Locations_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="H) Total Number of Locations Served by Type - Business (Actual)", json_schema_extra={"column": "BN", "treasury_report_col_1A": "BO"}, ) - Number_of_CAI_Planned__c: conint(ge=0, le=999999999) = Field( + Number_of_CAI_Planned__c: CustomInt_GE0_LELARGE = Field( ..., serialization_alias="I) Total Number of Locations Served by Type - Community Anchor Institution (Planned)", json_schema_extra={"column": "BO", "treasury_report_col_1A": "BP"}, ) - Number_of_CAI_Actual__c: Optional[conint(ge=0, le=999999999)] = Field( + Number_of_CAI_Actual__c: Optional[CustomInt_GE0_LELARGE] = Field( default=None, serialization_alias="I) Total Number of Locations Served by Type - Community Anchor Institution (Actual)", json_schema_extra={"column": "BP", "treasury_report_col_1A": "BQ"}, @@ -808,16 +803,14 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class AddressFields(BaseModel): - Street_1_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=40) = ( - Field( - ..., - serialization_alias="Street 1 (Planned)", - json_schema_extra={ - "column": "BS", - "treasury_report_col_1B": "AY", - "treasury_report_col_1C": "AY", - }, - ) + Street_1_Planned__c: CustomStr_MIN1_MAX40 = Field( + ..., + serialization_alias="Street 1 (Planned)", + json_schema_extra={ + "column": "BS", + "treasury_report_col_1B": "AY", + "treasury_report_col_1C": "AY", + }, ) Street_2_Planned__c: Optional[str] = Field( default=None, @@ -858,7 +851,7 @@ class AddressFields(BaseModel): "treasury_report_col_1C": "BB", }, ) - City_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=40) = Field( + City_Planned__c: CustomStr_MIN1_MAX40 = Field( ..., serialization_alias="City (Planned)", json_schema_extra={ @@ -895,16 +888,14 @@ class AddressFields(BaseModel): "treasury_report_col_1C": "BF", }, ) - Zip_Code_Planned__c: constr(strip_whitespace=True, min_length=1, max_length=5) = ( - Field( - ..., - serialization_alias="Zip Code (Planned)", - json_schema_extra={ - "column": "CB", - "treasury_report_col_1B": "BG", - "treasury_report_col_1C": "BG", - }, - ) + Zip_Code_Planned__c: CustomStr_MIN1_MAX5 = Field( + ..., + serialization_alias="Zip Code (Planned)", + json_schema_extra={ + "column": "CB", + "treasury_report_col_1B": "BG", + "treasury_report_col_1C": "BG", + }, ) Zip_Code_Actual__c: Optional[str] = Field( default=None, @@ -930,34 +921,32 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class Project1BRow(BaseProjectRow, AddressFields): - Laptops_Planned__c: conint(ge=0, le=9999999999) = Field( + Laptops_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Laptops (Planned)", json_schema_extra={"column": "CD", "treasury_report_col_1B": "BJ"}, ) - Laptops_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Laptops_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Laptops (Actual)", json_schema_extra={"column": "CE", "treasury_report_col_1B": "BK"}, ) - Laptops_Expenditures_Planned__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Laptops Expenditure (Planned)", - json_schema_extra={"column": "CF", "treasury_report_col_1B": "BL"}, - ) + Laptops_Expenditures_Planned__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Laptops Expenditure (Planned)", + json_schema_extra={"column": "CF", "treasury_report_col_1B": "BL"}, ) Laptops_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Laptops Expenditure (Actual)", json_schema_extra={"column": "CG", "treasury_report_col_1B": "BM"}, ) - Tablets_Planned__c: conint(ge=0, le=9999999999) = Field( + Tablets_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Tablets (Planned)", json_schema_extra={"column": "CH", "treasury_report_col_1B": "BN"}, ) - Tablets_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Tablets_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Tablets (Actual)", json_schema_extra={"column": "CI", "treasury_report_col_1B": "BO"}, @@ -972,12 +961,12 @@ class Project1BRow(BaseProjectRow, AddressFields): serialization_alias="Tablets Expenditure (Actual)", json_schema_extra={"column": "CK", "treasury_report_col_1B": "BQ"}, ) - Desktop_Computers_Planned__c: conint(ge=0, le=9999999999) = Field( + Desktop_Computers_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Desktop Computers (Planned)", json_schema_extra={"column": "CL", "treasury_report_col_1B": "BR"}, ) - Desktop_Computers_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Desktop_Computers_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Desktop Computers (Actual)", json_schema_extra={"column": "CM", "treasury_report_col_1B": "BS"}, @@ -987,43 +976,37 @@ class Project1BRow(BaseProjectRow, AddressFields): serialization_alias="Desktop Computers Expenditure (Planned)", json_schema_extra={"column": "CN", "treasury_report_col_1B": "BT"}, ) - Desktop_Computers_Expenditures_Actual__c: Optional[ - CustomDecimal_13Digits - ] = Field( + Desktop_Computers_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Desktop Computers Expenditure (Actual)", json_schema_extra={"column": "CO", "treasury_report_col_1B": "BU"}, ) - Public_WiFi_Planned__c: conint(ge=0, le=9999999999) = Field( + Public_WiFi_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Public WiFi (Planned)", json_schema_extra={"column": "CP", "treasury_report_col_1B": "BV"}, ) - Public_WiFi_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Public_WiFi_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Public WiFi (Actual)", json_schema_extra={"column": "CQ", "treasury_report_col_1B": "BW"}, ) - Public_WiFi_Expenditures_Planned__c: CustomDecimal_13Digits = ( - Field( - ..., - serialization_alias="Public Wifi Expenditures (Planned)", - json_schema_extra={"column": "CR", "treasury_report_col_1B": "BX"}, - ) + Public_WiFi_Expenditures_Planned__c: CustomDecimal_13Digits = Field( + ..., + serialization_alias="Public Wifi Expenditures (Planned)", + json_schema_extra={"column": "CR", "treasury_report_col_1B": "BX"}, ) - Public_WiFi_Expenditures_Actual__c: Optional[ - CustomDecimal_13Digits - ] = Field( + Public_WiFi_Expenditures_Actual__c: Optional[CustomDecimal_13Digits] = Field( default=None, serialization_alias="Public Wifi Expenditures (Actual)", json_schema_extra={"column": "CS", "treasury_report_col_1B": "BY"}, ) - Other_Devices_Planned__c: conint(ge=0, le=9999999999) = Field( + Other_Devices_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Other Devices (Planned)", json_schema_extra={"column": "CT", "treasury_report_col_1B": "BZ"}, ) - Other_Devices_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Devices_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Devices (Actual)", json_schema_extra={"column": "CU", "treasury_report_col_1B": "CA"}, @@ -1044,19 +1027,17 @@ class Project1BRow(BaseProjectRow, AddressFields): max_length=3000, json_schema_extra={"column": "CX", "treasury_report_col_1B": "CD"}, ) - Number_of_Users_Planned__c: conint(ge=0, le=9999999999) = Field( + Number_of_Users_Planned__c: CustomInt_GE0_LELARGE2 = Field( ..., serialization_alias="Number of Users (Planned)", json_schema_extra={"column": "CY", "treasury_report_col_1B": "CE"}, ) - Number_of_Users_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Number_of_Users_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Number of Users (Actual)", json_schema_extra={"column": "CZ", "treasury_report_col_1B": "CF"}, ) - Brief_Narrative_Planned__c: constr( - strip_whitespace=True, min_length=1, max_length=3000 - ) = Field( + Brief_Narrative_Planned__c: CustomStr_MIN1_MAX3000 = Field( ..., serialization_alias="Brief Narrative (Planned)", json_schema_extra={"column": "DA", "treasury_report_col_1B": "CG"}, @@ -1139,52 +1120,52 @@ class Project1CRow(BaseProjectRow, AddressFields): max_length=32000, json_schema_extra={"column": "DE", "treasury_report_col_1C": "BK"}, ) - Classrooms_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Classrooms_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Classrooms (Planned)", json_schema_extra={"column": "DF", "treasury_report_col_1C": "BL"}, ) - Classrooms_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Classrooms_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Classrooms (Actual)", json_schema_extra={"column": "DG", "treasury_report_col_1C": "BM"}, ) - Computer_labs_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Computer_labs_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Computer labs (Planned)", json_schema_extra={"column": "DH", "treasury_report_col_1C": "BN"}, ) - Computer_labs_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Computer_labs_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Computer labs (Actual)", json_schema_extra={"column": "DI", "treasury_report_col_1C": "BO"}, ) - Multi_purpose_Spaces_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Multi_purpose_Spaces_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Multi-purpose Spaces (Planned)", json_schema_extra={"column": "DJ", "treasury_report_col_1C": "BP"}, ) - Multi_purpose_Spaces_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Multi_purpose_Spaces_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Multi-purpose Spaces (Actual)", json_schema_extra={"column": "DK", "treasury_report_col_1C": "BQ"}, ) - Telemedicine_Rooms_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Telemedicine_Rooms_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Telemedicine Rooms (Planned)", json_schema_extra={"column": "DL", "treasury_report_col_1C": "BR"}, ) - Telemedicine_Rooms_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Telemedicine_Rooms_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Telemedicine Rooms (Actual)", json_schema_extra={"column": "DM", "treasury_report_col_1C": "BS"}, ) - Other_Capital_Assets_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Capital_Assets_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Capital Assets (Planned)", json_schema_extra={"column": "DN", "treasury_report_col_1C": "BT"}, ) - Other_Capital_Assets_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Other_Capital_Assets_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Other Capital Assets (Actual)", json_schema_extra={"column": "DO", "treasury_report_col_1C": "BU"}, @@ -1195,17 +1176,17 @@ class Project1CRow(BaseProjectRow, AddressFields): max_length=3000, json_schema_extra={"column": "DP", "treasury_report_col_1C": "BV"}, ) - Total_square_footage_Planned__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_square_footage_Planned__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total square footage (Planned)", json_schema_extra={"column": "DQ", "treasury_report_col_1C": "BW"}, ) - Total_square_footage_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_square_footage_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total square footage (Actual)", json_schema_extra={"column": "DR", "treasury_report_col_1C": "BX"}, ) - Total_Number_of_Users_Actual__c: Optional[conint(ge=0, le=9999999999)] = Field( + Total_Number_of_Users_Actual__c: Optional[CustomInt_GE0_LELARGE2] = Field( default=None, serialization_alias="Total Number of Users (Actual)", json_schema_extra={"column": "DS", "treasury_report_col_1C": "BY"}, @@ -1265,50 +1246,42 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class SubrecipientRow(BaseModel): model_config = ConfigDict(coerce_numbers_to_str=True, loc_by_alias=False) - Name: constr(strip_whitespace=True, min_length=1, max_length=80) = Field( + Name: CustomStr_MIN1_MAX80 = Field( ..., serialization_alias="Subrecipient Name", json_schema_extra={"column": "C", "output_column": "B"}, ) - Recipient_Profile_ID__c: Optional[ - constr(strip_whitespace=True, min_length=1, max_length=100) - ] = Field( + Recipient_Profile_ID__c: Optional[CustomStr_MIN1_MAX100] = Field( default=None, serialization_alias="Recipient ID", json_schema_extra={"column": "D", "output_column": "C"}, ) - EIN__c: constr(strip_whitespace=True, min_length=9, max_length=9) = Field( + EIN__c: CustomStr_MIN9_MAX9 = Field( ..., serialization_alias="Subrecipient Tax ID Number (TIN)", json_schema_extra={"column": "E", "output_column": "D"}, ) - Unique_Entity_Identifier__c: constr( - strip_whitespace=True, min_length=12, max_length=12 - ) = Field( + Unique_Entity_Identifier__c: CustomStr_MIN12_MAX12 = Field( ..., serialization_alias="Unique Entity Identifier (UEI)", json_schema_extra={"column": "F", "output_column": "E"}, ) - POC_Name__c: constr(strip_whitespace=True, min_length=1, max_length=100) = Field( + POC_Name__c: CustomStr_MIN1_MAX100 = Field( ..., serialization_alias="POC Name", json_schema_extra={"column": "G", "output_column": "F"}, ) - POC_Phone_Number__c: constr(strip_whitespace=True, min_length=1, max_length=10) = ( - Field( - ..., - serialization_alias="POC Phone Number", - json_schema_extra={"column": "H", "output_column": "G"}, - ) - ) - POC_Email_Address__c: constr(strip_whitespace=True, min_length=1, max_length=80) = ( - Field( - ..., - serialization_alias="POC Email Address", - json_schema_extra={"column": "I", "output_column": "H"}, - ) - ) - Zip__c: constr(strip_whitespace=True, min_length=1, max_length=5) = Field( + POC_Phone_Number__c: CustomStr_MIN1_MAX10 = Field( + ..., + serialization_alias="POC Phone Number", + json_schema_extra={"column": "H", "output_column": "G"}, + ) + POC_Email_Address__c: CustomStr_MIN1_MAX80 = Field( + ..., + serialization_alias="POC Email Address", + json_schema_extra={"column": "I", "output_column": "H"}, + ) + Zip__c: CustomStr_MIN1_MAX5 = Field( ..., serialization_alias="Zip5", json_schema_extra={"column": "J", "output_column": "I"}, @@ -1319,7 +1292,7 @@ class SubrecipientRow(BaseModel): max_length=4, json_schema_extra={"column": "K", "output_column": "J"}, ) - Address__c: constr(strip_whitespace=True, min_length=1, max_length=40) = Field( + Address__c: CustomStr_MIN1_MAX40 = Field( ..., serialization_alias="Address Line 1", json_schema_extra={"column": "L", "output_column": "K"}, @@ -1336,7 +1309,7 @@ class SubrecipientRow(BaseModel): max_length=40, json_schema_extra={"column": "N", "output_column": "M"}, ) - City__c: constr(strip_whitespace=True, min_length=1, max_length=100) = Field( + City__c: CustomStr_MIN1_MAX100 = Field( ..., serialization_alias="City", json_schema_extra={"column": "O", "output_column": "N"}, @@ -1394,10 +1367,10 @@ def validate_field(cls, v: Any, info: ValidationInfo, **kwargs): class CoverSheetRow(BaseModel): model_config = ConfigDict(loc_by_alias=False) - expenditure_category_group: constr(strip_whitespace=True, min_length=1) = Field( + expenditure_category_group: CustomStr_MIN1 = Field( ..., alias="Expenditure Category Group", json_schema_extra={"column": "A"} ) - detailed_expenditure_category: constr(strip_whitespace=True, min_length=1) = Field( + detailed_expenditure_category: CustomStr_MIN1 = Field( ..., alias="Detailed Expenditure Category", json_schema_extra={"column": "B"} ) diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 3c9345e9..df57b3f1 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -338,6 +338,7 @@ def sample_subrecipients_generation_event(): "outputTemplateId": 78, } + @pytest.fixture def sample_subrecipients_lambda_payload(): return SubrecipientLambdaPayload(