GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — typing: Improve FixtureDefinition and FixtureDef by nicoddemus · Pull Request #13036 · pytest-dev/pytest

Conversation

@nicoddemus

@nicoddemus nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member
  • Carry around parameters and return value in FixtureFunctionDefinition.
  • Add FixtureParams to FixtureDef.

Follow up to #12473.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nicoddemus nicoddemus mentioned this pull request Dec 7, 2024
typing: Improve FixtureDefinition and FixtureDef #12999
Closed
@nicoddemus nicoddemus added the skip news used on prs to opt out of the changelog requirement label Dec 7, 2024
@nicoddemus

nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member Author

cc @Glyphack

Glyphack reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus
typing: Improve FixtureDefinition and FixtureDef
0303285
* Carry around parameters and return value in `FixtureFunctionDefinition`.
* Add `FixtureParams` to `FixtureDef`.

Follow up to pytest-dev#12473.
@nicoddemus
nicoddemus force-pushed the typing-fixture-definition branch from ec71fce to 0303285 Compare December 7, 2024 13:03
@nicoddemus
nicoddemus requested review from RonnyPfannschmidt and bluetech and removed request for RonnyPfannschmidt December 7, 2024 13:04
@nicoddemus

nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member Author

Hmmm turns out pytest-bdd uses FixtureDef in a few places:

https://github.com/search?q=repo%3Apytest-dev%2Fpytest-bdd%20FixtureDef&type=code

The new Generic parameter breaks it, and there is no support for default values in Generic parameters yet...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bluetech

bluetech commented Dec 7, 2024

Copy link
Copy Markdown
Member

Is the FixtureDef change needed for the FixtureFunctionDefinition change?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member Author

Is the FixtureDef change needed for the FixtureFunctionDefinition change?

I don't think so. Should I try to keep only the change to FixtureFunctionDefinition?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

RonnyPfannschmidt
RonnyPfannschmidt reviewed Dec 7, 2024
View reviewed changes

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The paramspec types give me a slight headache as we basically resolve them internally and I wonder if there's a good way to make them work in passover

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/_pytest/fixtures.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/_pytest/python.py Outdated

# Used for storing pseudo fixturedefs for direct parametrization.
name2pseudofixturedef_key = StashKey[dict[str, FixtureDef[Any]]]()
name2pseudofixturedef_key = StashKey[dict[str, FixtureDef[Any, Any]]]()

@RonnyPfannschmidt RonnyPfannschmidt Dec 7, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm starting to get the impression we need a type alias for those dicts as they land in too many places

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nicoddemus nicoddemus Dec 7, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bluetech

bluetech commented Dec 7, 2024

Copy link
Copy Markdown
Member

I don't think so. Should I try to keep only the change to FixtureFunctionDefinition?

FixtureDef is internal and we mostly use object or Any as the type parameter, so if it breaks plugins we might as well keep it as is.

nicoddemus reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus
Use instance/owner for __get__
af0d67a
@nicoddemus

nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member Author

FixtureDef is internal and we mostly use object or Any as the type parameter, so if it breaks plugins we might as well keep it as is.

Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus
nicoddemus force-pushed the typing-fixture-definition branch from f002e4a to 889d9b8 Compare December 7, 2024 22:52
nicoddemus added 2 commits December 7, 2024 19:53
@nicoddemus
Revert FixtureDef to a single argument
9f78c6c
@nicoddemus
Add FixtureDefDict type alias
348068c
@nicoddemus
nicoddemus force-pushed the typing-fixture-definition branch from 889d9b8 to 348068c Compare December 7, 2024 22:53
@nicoddemus

nicoddemus commented Dec 7, 2024

Copy link
Copy Markdown
Member Author

TBH I'm second guessing if this is useful at all. In the end we cannot do proper type checking because we need to keep all the FixtureDefinition instances in the same data structure, so it all ends up being Any anyway...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bluetech

bluetech commented Dec 8, 2024

Copy link
Copy Markdown
Member

I agree for FixtureDef, but FixtureFunctionDefinition is not stored in any datastructure, it's a decorator which wraps fixture functions. I think we should try to preserve the typing of fixture functions, even if we don't allow calling them. I can imagine some e.g. mypy plugin introspecting it. Also IDEs, etc.

RonnyPfannschmidt reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus

nicoddemus commented Feb 8, 2025

Copy link
Copy Markdown
Member Author

Unfortunately I won't have time to continue this, so I will be closing given is a "nice to have" feature.

If anybody wants to continue from this point please be my guest!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicoddemus nicoddemus closed this Feb 8, 2025
@teddygood teddygood mentioned this pull request Aug 15, 2026
feat: expose FixtureFunctionDefinition for typing #14862
Open
@bluetech bluetech mentioned this pull request Aug 20, 2026
Expose FixtureFunctionDefinition as part of the public API #14853
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@RonnyPfannschmidt RonnyPfannschmidt RonnyPfannschmidt left review comments
@bluetech bluetech Awaiting requested review from bluetech

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news used on prs to opt out of the changelog requirement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@nicoddemus @bluetech @RonnyPfannschmidt
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.