Skip to content

Fix Any overloads for inspect() raiseerr handling - #13710

Closed
princejain756 wants to merge 3 commits into
sqlalchemy:mainfrom
princejain756:fix-13704-inspect-overloads
Closed

princejain756 wants to merge 3 commits into
sqlalchemy:mainfrom
princejain756:fix-13704-inspect-overloads

Conversation

@princejain756

Copy link
Copy Markdown
Contributor

Fixes

Fixes: #13704

Description

Update the fallback @overload signatures for inspect(subject: Any, ...) in lib/sqlalchemy/inspection.py so the default raiseerr: Literal[True] = ... -> Any overload precedes raiseerr: bool -> Optional[Any]:

  • Calling inspect(obj) with raiseerr omitted or True now resolves to Any instead of Any | None.
  • Calling inspect(obj, raiseerr=flag) with False or a bool variable now resolves to Optional[Any] (Any | None).
  • Extend test/typing/plain_files/inspection_inspect.py to cover omitted raiseerr, literal booleans, and a bool parameter on a Protocol-typed subject.

@sqla-tester

Copy link
Copy Markdown
Collaborator

Thanks! Issue #13704 is now marked code review in progress and no longer open for pull requests, so this pull request holds the review for it and another one won't land on top of your work. If this pull request is abandoned, a maintainer can put open for pull requests back on #13704 to reopen it to others.

@CaselIT

CaselIT commented Oct 21, 2026

Copy link
Copy Markdown
Member

thanks, looks ok!

@CaselIT
CaselIT requested a review from sqla-tester October 23, 2026 07:31

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision 1078553 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester

Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Michael Bayer (zzzeek) wrote:

need to remove that comment, otherwise looks good

View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/7122

Comment thread lib/sqlalchemy/orm/strategy_options.py Resolved
@CaselIT
CaselIT requested a review from sqla-tester October 23, 2026 16:58

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision c5097c9 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester

Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Michael Bayer (zzzeek) wrote:

Code-Review+2 Workflow+2

(1 comment)

View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/7122

# inspect(), it should not have None as an option in most cases
# if at all
insp: InspectionAttr = inspect(attr) # type: ignore[assignment]
insp: InspectionAttr = inspect(attr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sqla-tester

Copy link
Copy Markdown
Collaborator

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.

Inspect overloads for Any handle raiseerr wrong

3 participants