Skip to content

[ty] Add support for functional Enum(...) syntax#23602

Merged
charliermarsh merged 9 commits intoastral-sh:mainfrom
thejchap:thejchap/enum-func-syntax
Apr 11, 2026
Merged

[ty] Add support for functional Enum(...) syntax#23602
charliermarsh merged 9 commits intoastral-sh:mainfrom
thejchap:thejchap/enum-func-syntax

Conversation

@thejchap
Copy link
Copy Markdown
Contributor

@thejchap thejchap commented Feb 27, 2026

Summary

astral-sh/ty#876
https://typing.python.org/en/latest/spec/enums.html#enum-definition

this pr implements the functional syntax for creating enums: Enum('Color2', 'RED, GREEN, BLUE')

it mostly copies the namedtuple implementation

it supports the start= and type= kwargs for Enum as well (docs)

it also supports Flag and IntFlag

the ddtrace diffs look to be correct - IntEnum call is now properly recognized

for non-string-literal name arguments, it falls back to just returning type[Enum] - this came up by way of a psycopg regression on this line - wasn't sure if this was better or worse than returning a DynamicEnumLiteral with an unknown name and members.

this now looks correct for psycopg: + psycopg/psycopg/types/enum.py:173:12 [error] [invalid-return-type] Return type does not match returned value: expected Enum, found type[Enum]``

however, it appears mypy does not correctly support the functional API (i am wondering if this is why the psycopg typing is the way it is), or maybe when just returning the result of the Enum call (without assigning it to a name), it always assumes its looking up a member:

from enum import Enum, EnumType
from typing import reveal_type


def make_color_1() -> EnumType:
    return Enum("Color1", names="RED GREEN")


def make_color_2() -> EnumType:
    return Enum("Color2", names=("RED", "GREEN"))


reveal_type(make_color_1())
reveal_type(make_color_2())
# mypy output

main.py:6: error: Incompatible return value type (got "Enum", expected "EnumMeta")  [return-value]
main.py:10: error: Incompatible return value type (got "Enum", expected "EnumMeta")  [return-value]
main.py:13: note: Revealed type is "enum.EnumMeta"
main.py:14: note: Revealed type is "enum.EnumMeta"
Found 2 errors in 1 file (checked 1 source file)

# runtime output
Runtime type is 'EnumType'
Runtime type is 'EnumType'

Test Plan

mdtests

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 27, 2026

Typing conformance results improved 🎉

The percentage of diagnostics emitted that were expected errors increased from 87.90% to 87.92%. The percentage of expected errors that received a diagnostic increased from 83.08% to 83.11%. The number of fully passing files held steady at 78/133.

Summary

How are test cases classified?

Each test case represents one expected error annotation or a group of annotations sharing a tag. Counts are per test case, not per diagnostic — multiple diagnostics on the same line count as one. Required annotations (E) are true positives when ty flags the expected location and false negatives when it does not. Optional annotations (E?) are true positives when flagged but true negatives (not false negatives) when not. Tagged annotations (E[tag]) require ty to flag exactly one of the tagged lines; tagged multi-annotations (E[tag+]) allow any number up to the tag count. Flagging unexpected locations counts as a false positive.

Metric Old New Diff Outcome
True Positives 879 881 +2 ⏫ (✅)
False Positives 121 121 +0
False Negatives 179 179 +0
Total Diagnostics 1050 1052 +2
Precision 87.90% 87.92% +0.02% ⏫ (✅)
Recall 83.08% 83.11% +0.03% ⏫ (✅)
Passing Files 78/133 78/133 +0

Test file breakdown

1 file altered
File True Positives False Positives False Negatives Status
enums_definition.py 2 (+2) ✅ 0 0 ✅ Still Passing
Total (all files) 881 (+2) ✅ 121 179 78/133

Optional Diagnostics Added (2)

2 diagnostics
Test case Diff

enums_definition.py:24

+error[too-many-positional-arguments] Too many positional arguments to function `Enum`: expected 2, got 4

enums_definition.py:33

+error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 27, 2026

mypy_primer results

Changes were detected when running on open source projects
bidict (https://github.com/jab/bidict)
+ bidict/_base.py:400:22: error[invalid-argument-type] Argument to bound method `__delitem__` is incorrect: Expected `KT@BidictBase`, found `KT@BidictBase | MissingT`
+ bidict/_base.py:401:22: error[invalid-argument-type] Argument to bound method `__delitem__` is incorrect: Expected `VT@BidictBase`, found `VT@BidictBase | MissingT`
+ bidict/_base.py:411:22: error[invalid-argument-type] Argument to bound method `__delitem__` is incorrect: Expected `VT@BidictBase`, found `VT@BidictBase | MissingT`
+ bidict/_base.py:421:22: error[invalid-argument-type] Argument to bound method `__delitem__` is incorrect: Expected `KT@BidictBase`, found `KT@BidictBase | MissingT`
+ bidict/_bidict.py:143:20: error[invalid-return-type] Return type does not match returned value: expected `VT@MutableBidict | DT@pop`, found `DT@pop | MissingT`
- Found 18 diagnostics
+ Found 23 diagnostics

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/types/enum.py:173:12: error[invalid-return-type] Return type does not match returned value: expected `Enum`, found `<class '<unknown>'>`
- Found 669 diagnostics
+ Found 670 diagnostics

discord.py (https://github.com/Rapptz/discord.py)
+ discord/http.py:571:53: error[invalid-argument-type] Argument to bound method `ws_connect` is incorrect: Expected `ClientWSTimeout | _SENTINEL`, found `BasicAuth | None | str | ... omitted 4 union elements`
- Found 558 diagnostics
+ Found 559 diagnostics

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/build/wheel.py:99:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 59 diagnostics
+ Found 60 diagnostics

core (https://github.com/home-assistant/core)
- homeassistant/components/http/forwarded.py:213:47: warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- Found 12090 diagnostics
+ Found 12089 diagnostics

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Feb 27, 2026

Memory usage report

Summary

Project Old New Diff Outcome
prefect 707.79MB 707.80MB +0.00% (10.41kB)
flake8 47.81MB 47.82MB +0.02% (9.32kB)
trio 117.33MB 117.33MB +0.00% (5.77kB)
sphinx 261.87MB 261.87MB -0.00% (1004.00B) ⬇️

Significant changes

Click to expand detailed breakdown

prefect

Name Old New Diff Outcome
enum_metadata 2.66MB 2.67MB +0.38% (10.49kB)
StaticClassLiteral<'db>::is_typed_dict_ 627.15kB 627.04kB -0.02% (120.00B)
infer_definition_types 89.78MB 89.78MB +0.00% (36.00B)

flake8

Name Old New Diff Outcome
all_narrowing_constraints_for_expression 81.36kB 82.44kB +1.33% (1.08kB)
Type<'db>::class_member_with_policy_ 578.43kB 579.29kB +0.15% (884.00B)
StaticClassLiteral<'db>::try_mro_ 318.75kB 319.50kB +0.24% (772.00B)
infer_expression_types_impl 1.04MB 1.04MB +0.07% (768.00B)
enum_metadata 64.81kB 65.55kB +1.15% (760.00B)
Type<'db>::try_call_dunder_get_ 367.62kB 368.19kB +0.15% (580.00B)
Type<'db>::apply_specialization_ 214.24kB 214.75kB +0.24% (524.00B)
Type<'db>::class_member_with_policy_::interned_arguments 311.49kB 312.00kB +0.16% (520.00B)
Type<'db>::member_lookup_with_policy_ 482.14kB 482.61kB +0.10% (472.00B)
Specialization 161.66kB 162.06kB +0.25% (416.00B)
all_negative_narrowing_constraints_for_expression 39.18kB 39.55kB +0.96% (384.00B)
FunctionType 439.55kB 439.91kB +0.08% (368.00B)
Type<'db>::apply_specialization_::interned_arguments 205.16kB 205.47kB +0.15% (320.00B)
UnionType 89.88kB 89.56kB -0.35% (320.00B)
code_generator_of_static_class 60.77kB 61.05kB +0.47% (292.00B)
... 25 more

trio

Name Old New Diff Outcome
IntersectionType 199.99kB 201.64kB +0.82% (1.65kB)
is_redundant_with_impl::interned_arguments 505.74kB 507.29kB +0.31% (1.55kB)
all_negative_narrowing_constraints_for_expression 182.92kB 183.98kB +0.58% (1.07kB)
infer_expression_types_impl 7.03MB 7.03MB +0.01% (924.00B)
infer_expression_type_impl 1.31MB 1.31MB +0.06% (756.00B)
is_redundant_with_impl 438.74kB 439.46kB +0.17% (744.00B)
UnionType 284.98kB 285.50kB +0.18% (528.00B)
Type<'db>::class_member_with_policy_ 2.05MB 2.05MB -0.02% (496.00B)
Type<'db>::try_call_dunder_get_ 1.34MB 1.34MB -0.03% (472.00B)
Type<'db>::class_member_with_policy_::interned_arguments 1.13MB 1.13MB -0.04% (416.00B)
infer_definition_types 7.62MB 7.61MB -0.01% (416.00B)
UnionType<'db>::from_two_elements_ 272.37kB 272.75kB +0.14% (388.00B)
EnumLiteralType 13.94kB 14.23kB +2.02% (288.00B)
IntersectionType<'db>::from_two_elements_ 17.01kB 17.27kB +1.54% (268.00B)
FunctionType 1.49MB 1.49MB -0.01% (224.00B)
... 20 more

sphinx

Name Old New Diff Outcome
enum_metadata 705.72kB 706.70kB +0.14% (996.00B) ⬇️
Type<'db>::class_member_with_policy_ 7.64MB 7.64MB -0.01% (496.00B) ⬇️
Type<'db>::try_call_dunder_get_ 4.88MB 4.88MB -0.01% (472.00B) ⬇️
Type<'db>::class_member_with_policy_::interned_arguments 4.03MB 4.03MB -0.01% (416.00B) ⬇️
Type<'db>::member_lookup_with_policy_ 6.25MB 6.25MB -0.00% (136.00B) ⬇️
StaticClassLiteral<'db>::is_typed_dict_ 182.60kB 182.48kB -0.06% (120.00B) ⬇️
Type<'db>::member_lookup_with_policy_::interned_arguments 2.67MB 2.67MB -0.00% (104.00B) ⬇️
Type<'db>::try_call_dunder_get_::interned_arguments 1.16MB 1.16MB -0.01% (104.00B) ⬇️
enum_ignored_names 3.19kB 3.09kB -2.94% (96.00B) ⬇️
BoundMethodType 708.05kB 707.97kB -0.01% (80.00B) ⬇️
infer_definition_types 23.76MB 23.76MB +0.00% (36.00B) ⬇️
infer_scope_types_impl 15.44MB 15.44MB -0.00% (12.00B) ⬇️

@ntBre ntBre added the ty Multi-file analysis & type inference label Feb 27, 2026
@charliermarsh charliermarsh self-assigned this Feb 27, 2026
@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch 2 times, most recently from dbb7622 to da0c825 Compare February 28, 2026 06:11
@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch 2 times, most recently from e3f84c6 to 5eae9a2 Compare March 10, 2026 04:07
@thejchap thejchap marked this pull request as ready for review March 10, 2026 04:15
@astral-sh-bot astral-sh-bot Bot requested a review from charliermarsh March 10, 2026 04:15
Copy link
Copy Markdown

@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.

Reviewed commit: 5eae9a2f9b

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/class/enum_literal.rs Outdated
@carljm carljm removed their request for review March 11, 2026 05:17
@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from 5eae9a2 to 1baf73c Compare March 21, 2026 12:57
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented Mar 21, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 3 0 0
unresolved-attribute 0 3 0
call-non-callable 0 1 0
invalid-return-type 1 0 0
Total 4 4 0

Raw diff:

core (https://github.com/home-assistant/core)
+ homeassistant/components/http/forwarded.py:213:33 error[invalid-argument-type] Argument to bound method `clone` is incorrect: Expected `Mapping[str, str] | Mapping[istr, str] | Iterable[tuple[str, str]] | _SENTINEL`, found `str`
+ homeassistant/components/http/forwarded.py:213:33 error[invalid-argument-type] Argument to bound method `clone` is incorrect: Expected `int | _SENTINEL`, found `str`

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/vendor/psutil/_psposix.py:56:16 error[call-non-callable] Object of type `IntEnum` is not callable
- ddtrace/vendor/psutil/_pslinux.py:96:11 error[unresolved-attribute] Object of type `IntEnum` has no attribute `AF_LINK`
- ddtrace/vendor/psutil/_pswindows.py:82:11 error[unresolved-attribute] Object of type `IntEnum` has no attribute `AF_LINK`

discord.py (https://github.com/Rapptz/discord.py)
+ discord/http.py:571:53 error[invalid-argument-type] Argument to bound method `ws_connect` is incorrect: Expected `ClientWSTimeout | _SENTINEL`, found `ClientWSTimeout | float`

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/types/enum.py:173:12 error[invalid-return-type] Return type does not match returned value: expected `Enum`, found `type[Enum]`

pybind11 (https://github.com/pybind/pybind11)
- tests/test_native_enum.py:117:41 error[unresolved-attribute] Object of type `IntEnum` has no attribute `mem`

Full report with detailed diff (timing results)

Copy link
Copy Markdown

@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.

Reviewed commit: 1baf73cfe0

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Copy link
Copy Markdown

@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.

Reviewed commit: 893448a30b

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/class/enum_literal.rs Outdated
Copy link
Copy Markdown

@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.

Reviewed commit: d41b7b9b4b

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from 3cc298d to 33a4cb3 Compare March 22, 2026 15:36
Copy link
Copy Markdown

@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.

Reviewed commit: 33a4cb37a6

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
Copy link
Copy Markdown

@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.

Reviewed commit: 25b76f106b

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/enums.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
@thejchap thejchap marked this pull request as draft March 22, 2026 18:12
Copy link
Copy Markdown

@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.

Reviewed commit: de88e98c1e

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@thejchap thejchap marked this pull request as ready for review March 24, 2026 02:10
Copy link
Copy Markdown

@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.

Reviewed commit: d08281f5f3

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@charliermarsh
Copy link
Copy Markdown
Member

I'm wondering if the shape here should be closer to functional TypedDict and type(...) whereby we defer inference of various fields (like type). But I haven't been able to come up with a real, runtime-valid example where that matters. Did you consider it?

@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from c31e542 to 3dd7d3a Compare April 8, 2026 22:57
Copy link
Copy Markdown

@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.

Reviewed commit: 3dd7d3a8c7

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/class/enum_literal.rs Outdated
@thejchap
Copy link
Copy Markdown
Contributor Author

thejchap commented Apr 9, 2026

we defer inference of various fields ... Did you consider it?

truthfully i hadn't considered it - let me just make sure i understand

for TypedDict we want to defer field type inference until after scope inference because of valid forward-declaration situations like this:

Line = TypedDict('Line', {'start': Point, 'end': Point})
Point = TypedDict('Point', {'x': int, 'y': int})

for Enums, a contrived/invalid example would be something like:

Color = Enum('Color', {'RED': BASE, 'GREEN': BASE + 1, 'BLUE': BASE + 2})
BASE = 10

but to your point that's not a runtime-valid example

either way, i'll defer to you - if there are other reasons to reimplement using deferred inference (consistency with TypedDict or anything else) i'm happy to do so!

still need to work through the static enum parity comment but otherwise i think i got the rest of the pr feedback

@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from 3dd7d3a to 49a4939 Compare April 9, 2026 02:15
Copy link
Copy Markdown

@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.

Reviewed commit: 49a4939e7e

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@charliermarsh
Copy link
Copy Markdown
Member

As an example of deferred inference, you need to defer the fields to support cases like:

Tree = TypedDict(
    "Tree",
    {
        "value": int,
        "left": "Tree | None",
        "right": "Tree | None",
    },
)

So generally it's only needed to support type annotation on the right-hand side. It seems like the type= field accepts an annotation... but it doesn't accept forward references, since it needs to be accessible at runtime? In which case, we shouldn't need to defer.

Copy link
Copy Markdown

@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.

Reviewed commit: bde7eb43b9

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@thejchap
Copy link
Copy Markdown
Contributor Author

thejchap commented Apr 9, 2026

hmm i don't think it even takes an annotation

`type`, if set, will be mixed in as the first base class.
- just a plain class object

@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from e037472 to c547cfa Compare April 11, 2026 16:21
Copy link
Copy Markdown

@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.

Reviewed commit: c547cfacb8

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/enums.rs
@thejchap thejchap force-pushed the thejchap/enum-func-syntax branch from c547cfa to eac265b Compare April 11, 2026 16:34
Copy link
Copy Markdown

@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.

Reviewed commit: eac265b292

ℹ️ 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
Comment thread crates/ty_python_semantic/src/types/infer/builder/enum_call.rs Outdated
@thejchap
Copy link
Copy Markdown
Contributor Author

@charliermarsh ive addressed this comment and think this is ready for another look

@charliermarsh charliermarsh self-requested a review April 11, 2026 18:02
@charliermarsh
Copy link
Copy Markdown
Member

(Iterating on this a bit with Codex to catch some last cases, then I'll merge later today hopefully.)

@charliermarsh charliermarsh changed the title [ty] functional enum syntax [ty] Add support for functional Enum(...) syntax Apr 11, 2026
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this!

@charliermarsh charliermarsh merged commit b642756 into astral-sh:main Apr 11, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants