Skip to content

Add fix for typing.Required forward references#544

Merged
agronholm merged 10 commits intoagronholm:masterfrom
dionhaefner:master
Feb 6, 2026
Merged

Add fix for typing.Required forward references#544
agronholm merged 10 commits intoagronholm:masterfrom
dionhaefner:master

Conversation

@dionhaefner
Copy link
Copy Markdown
Contributor

@dionhaefner dionhaefner commented Feb 4, 2026

Changes

Fixes an issue when using Required forward annotations like this:

class MyDict(TypedDict):
    foo: "Required[int]"

which cause typeguard to not complain when foo isn't provided. There's already logic to handle NotRequired in the same way, this adds the equivalent for Required.

Also fixes #533 (missing inner type validation).

Checklist

If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):

  • You've added tests (in tests/) added which would fail without your patch
  • You've updated the documentation (in docs/, in case of behavior changes or new
    features)
  • You've added a new changelog entry (in docs/versionhistory.rst).

If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.

Updating the changelog

If there are no entries after the last release, use **UNRELEASED** as the version.
If, say, your patch fixes issue #999, the entry should look like this:

* Fix big bad boo-boo in the pytest plugin (#999 <https://github.com/agronholm/typeguard/issues/999>_; PR by @yourgithubaccount)

If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 4, 2026

Coverage Status

coverage: 94.743% (+0.009%) from 94.734%
when pulling c0b5523 on dionhaefner:master
into be72808 on agronholm:master.

@agronholm
Copy link
Copy Markdown
Owner

agronholm commented Feb 6, 2026

This fixes #533, right? If so, please add the appropriate issue link to the changelog entry.

@dionhaefner
Copy link
Copy Markdown
Contributor Author

That wasn't the original intent but it actually does fix the issue as a side effect :) Added a regression test for that one specifically.

Copy link
Copy Markdown
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@agronholm agronholm merged commit 5b4e934 into agronholm:master Feb 6, 2026
11 checks passed
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.

Required[Type] does not trigger type checking for Type

3 participants