From 6f927819f2a0f1863f1d721ceb998b2ced94e24f Mon Sep 17 00:00:00 2001 From: zhibindai26 <11509096+zhibindai26@users.noreply.github.com> Date: Tue, 14 Apr 2026 11:20:29 -0500 Subject: [PATCH] remove mutable param --- parcllabs/schemas/schemas.py | 13 ++++++------- .../services/metrics/portfolio_size_service.py | 6 ++++-- parcllabs/services/metrics/property_type_service.py | 6 ++++-- .../services/properties/property_events_service.py | 6 ++++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/parcllabs/schemas/schemas.py b/parcllabs/schemas/schemas.py index 2a27f66..11aca06 100644 --- a/parcllabs/schemas/schemas.py +++ b/parcllabs/schemas/schemas.py @@ -5,7 +5,7 @@ from datetime import datetime from typing import Any -from pydantic import BaseModel, Field, ValidationInfo, field_validator +from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, field_validator from parcllabs.enums import PropertyTypes, RequestLimits @@ -328,12 +328,11 @@ def validate_record_updated_date_range(cls, v: str | None, info: ValidationInfo) ) return v - class Config: - """Pydantic configuration.""" - - extra = "forbid" # Reject any extra fields - validate_assignment = True # Validate on assignment - str_strip_whitespace = True # Strip whitespace from strings + model_config = ConfigDict( + extra="forbid", + validate_assignment=True, + str_strip_whitespace=True, + ) class PropertyV2RetrieveParamCategories(BaseModel): diff --git a/parcllabs/services/metrics/portfolio_size_service.py b/parcllabs/services/metrics/portfolio_size_service.py index 9585e18..1d1ec2a 100644 --- a/parcllabs/services/metrics/portfolio_size_service.py +++ b/parcllabs/services/metrics/portfolio_size_service.py @@ -1,4 +1,3 @@ -from collections.abc import Mapping from typing import Any import pandas as pd @@ -14,12 +13,15 @@ def retrieve( end_date: str | None = None, portfolio_size: str | None = None, limit: int | None = None, - params: Mapping[str, Any] | None = {}, + params: dict[str, Any] | None = None, auto_paginate: bool = False, ) -> pd.DataFrame: """ Retrieve portfolio size metrics for given parameters. """ + if params is None: + params = {} + if portfolio_size: params["portfolio_size"] = portfolio_size.upper() diff --git a/parcllabs/services/metrics/property_type_service.py b/parcllabs/services/metrics/property_type_service.py index b04d81e..aa4a194 100644 --- a/parcllabs/services/metrics/property_type_service.py +++ b/parcllabs/services/metrics/property_type_service.py @@ -1,4 +1,3 @@ -from collections.abc import Mapping from typing import Any import pandas as pd @@ -14,12 +13,15 @@ def retrieve( end_date: str | None = None, property_type: str | None = None, limit: int | None = None, - params: Mapping[str, Any] | None = {}, + params: dict[str, Any] | None = None, auto_paginate: bool = False, ) -> pd.DataFrame: """ Retrieve property type metrics for given parameters. """ + if params is None: + params = {} + if property_type: params["property_type"] = property_type.upper() diff --git a/parcllabs/services/properties/property_events_service.py b/parcllabs/services/properties/property_events_service.py index 2d01cf6..5cd05bd 100644 --- a/parcllabs/services/properties/property_events_service.py +++ b/parcllabs/services/properties/property_events_service.py @@ -1,5 +1,4 @@ from collections import deque -from collections.abc import Mapping from concurrent.futures import ThreadPoolExecutor, as_completed from typing import Any @@ -67,11 +66,14 @@ def retrieve( entity_owner_name: str | None = None, record_updated_date_start: str | None = None, record_updated_date_end: str | None = None, - params: Mapping[str, Any] | None = {}, + params: dict[str, Any] | None = None, ) -> pd.DataFrame: """ Retrieve property events for given parameters. """ + if params is None: + params = {} + params = self._prepare_params( event_type=event_type, start_date=start_date,