Skip to content

Remove UP007/UP045 ignores and fix guess_field_type for UnionType#8977

Draft
ogenstad wants to merge 1 commit intodevelopfrom
pog-20260420-up-rules
Draft

Remove UP007/UP045 ignores and fix guess_field_type for UnionType#8977
ogenstad wants to merge 1 commit intodevelopfrom
pog-20260420-up-rules

Conversation

@ogenstad
Copy link
Copy Markdown
Contributor

@ogenstad ogenstad commented Apr 20, 2026

Why

Update to use modern version of optional types.

What changed

  • Fix Optional[X] -> X | None and Union[X,Y] -> X | Y across branch/models.py, graph/constraints.py, graph/schema.py, and node/standard.py; remove dead UP007 ignore for core/query/**.py.

  • The guess_field_type method now checks for both typing.Union and types.UnionType so that X | None fields are handled correctly at runtime in to_db/from_db after the annotation syntax change.


Summary by cubic

Migrate type hints to PEP 604 unions (X | Y) and fix runtime type detection so X | None fields serialize/deserialize correctly. Removes now-unneeded UP007/UP045 ignores.

  • Bug Fixes

    • Update guess_field_type to recognize both typing.Union and types.UnionType, ensuring X | None works in to_db/from_db.
  • Refactors

    • Replace Optional[X] with X | None and Union[X, Y] with X | Y in core/branch/models.py, core/graph/{constraints.py,schema.py}, and core/node/standard.py.
    • Clean up linter config by removing UP007/UP045 ignores in pyproject.toml (including the dead core/query/**.py rule).

Written for commit 2c1b450. Summary will update on new commits.

Fix Optional[X] -> X | None and Union[X,Y] -> X | Y across
branch/models.py, graph/constraints.py, graph/schema.py, and
node/standard.py; remove dead UP007 ignore for core/query/**.py.

The guess_field_type method now checks for both typing.Union and
types.UnionType so that X | None fields are handled correctly at
runtime in to_db/from_db after the annotation syntax change.
@github-actions github-actions Bot added the group/backend Issue related to the backend (API Server, Git Agent) label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 20, 2026

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing pog-20260420-up-rules (2c1b450) with develop (4a132a6)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant