Skip to content

Conversation

@adityamehra
Copy link
Collaborator

@adityamehra adityamehra commented Oct 10, 2025

Description

  • Make genai util compatible with 3.9

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Comment on lines 108 to 113
categories: Sequence[str],
method_name: str,
*,
obj: Any | None = None,
error: Error | None = None,
obj: Union[Any, None] = None,
error: Union[Error, None] = None,
results: Sequence[EvaluationResult] | None = None,

Choose a reason for hiding this comment

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

P1 Badge Replace remaining union operators for Python 3.9 compatibility

The CompositeEmitter changes switch some annotations to typing.Union, but _dispatch still declares results: Sequence[EvaluationResult] | None. Python 3.9 cannot parse the | type-union syntax, so importing this module on 3.9 will still raise a SyntaxError. For the stated goal of 3.9 support, the remaining | usages in this file (e.g. Sequence[str] | None in the constructor and iterator helpers) also need to be converted to Union[...] or Optional[...].

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@codex How were you integrated on this and what can be done to get more helpful reviews from you?

Choose a reason for hiding this comment

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

Comment on lines 37 to 41
self,
metrics: Iterable[str] | None = None,
*,
invocation_type: str | None = None,
invocation_type: Union[str, None] = None,
options: Mapping[str, str] | None = None,

Choose a reason for hiding this comment

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

P1 Badge Evaluator constructor still uses PEP 604 unions

Although Union is now imported, the Evaluator initializer keeps metrics: Iterable[str] | None and options: Mapping[str, str] | None. These annotations still rely on the Python 3.10 union operator and will fail to parse on Python 3.9, so the module remains incompatible with the version this change targets. Converting these to Union[Iterable[str], None] (or Optional) is required for true 3.9 support.

Useful? React with 👍 / 👎.

Comment on lines 46 to 50
target: EvaluatorFactory,
*,
metrics: Sequence[str] | None = None,
invocation_type: str | None = None,
invocation_type: Union[str, None] = None,
options: Mapping[str, str] | None = None,

Choose a reason for hiding this comment

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

P1 Badge Registry helpers still contain Python 3.10-only union syntax

The registry’s _call_with_optional_params function continues to annotate parameters with metrics: Sequence[str] | None and options: Mapping[str, str] | None. These annotations use the | union operator that is unavailable in Python 3.9, so importing this module will still raise a syntax error even after this patch. To make the genai util package 3.9 compatible, these remaining unions need to be rewritten using typing.Union/Optional as done elsewhere.

Useful? React with 👍 / 👎.

@adityamehra
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

@adityamehra adityamehra changed the title make genai util compatible with 3.9 make otel util genai compatible with 3.9 Oct 13, 2025
@adityamehra adityamehra mentioned this pull request Oct 13, 2025
11 tasks
@adityamehra adityamehra force-pushed the fix/make-genai-util-compatible-with-python3.9 branch 2 times, most recently from 0da85b4 to 022f242 Compare October 13, 2025 18:40
@adityamehra adityamehra force-pushed the fix/make-genai-util-compatible-with-python3.9 branch from 022f242 to 35edb49 Compare October 14, 2025 18:08
@adityamehra adityamehra changed the title make otel util genai compatible with 3.9 fix: make otel util genai compatible with 3.9 Oct 20, 2025
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