Skip to content

Conversation

Copy link

Copilot AI commented Jan 3, 2026

Validator methods using cls parameter lacked explicit @classmethod decorators, violating Python naming conventions that methods with cls should be classmethods.

Changes

  • Updated unified_validator decorator to extract the underlying function from @classmethod wrappers when present
  • Added @classmethod decorators to all validator methods: ensure_keys, validate_addr, validate_comm_error_ctr, validate_ventilation_fields, extract_sensor_values, set_optional_enum
  • Added documentation explaining decorator stacking order and usage pattern

Example

Before:

@unified_validator()
def validate_addr(cls, values: dict[str, dict | str | int]) -> dict[str, dict | str | int]:
    values["Addr"] = extract_val(values.get("Addr", {}))
    return values

After:

@unified_validator()
@classmethod
def validate_addr(cls, values: dict[str, dict | str | int]) -> dict[str, dict | str | int]:
    values["Addr"] = extract_val(values.get("Addr", {}))
    return values

The validators receive the class (not instance) from Pydantic's @root_validator/@model_validator, making @classmethod semantically correct.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Jan 3, 2026
Copilot AI and others added 4 commits January 3, 2026 15:34
…ventions

Co-authored-by: stuartp44 <1926002+stuartp44@users.noreply.github.com>
Co-authored-by: stuartp44 <1926002+stuartp44@users.noreply.github.com>
Co-authored-by: stuartp44 <1926002+stuartp44@users.noreply.github.com>
Co-authored-by: stuartp44 <1926002+stuartp44@users.noreply.github.com>
Copilot AI changed the title [WIP] Update CI, publish, and release workflows based on feedback Add explicit @classmethod decorators to Pydantic validator methods Jan 3, 2026
Copilot AI requested a review from stuartp44 January 3, 2026 15:38
@stuartp44 stuartp44 marked this pull request as ready for review January 7, 2026 12:23
@stuartp44 stuartp44 merged commit 48961a7 into stu/add_ci_pipeline Jan 7, 2026
@stuartp44 stuartp44 deleted the copilot/sub-pr-8-again branch January 7, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants