Skip to content

fix(snapshot): Support args with skip_snapshot_verify marker #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregfurman
Copy link

@gregfurman gregfurman commented Jun 23, 2025

Motivation

Currently, the skip_snapshot_verify marker only accepts paths as **kwargs -- where passing in positional *args end up being skipped and not used.

Changes

  • Check if args are defined, unpack them, and assign skip paths & conditions correctly.

TODO

  • This will potentially cause some tests that otherwise went unsnapshotted to fail in our pipelines. We should trigger a full run with this feature branch and identify failing tests before merging

@gregfurman gregfurman self-assigned this Jun 23, 2025
@gregfurman gregfurman added the bug Something isn't working label Jun 23, 2025
@gregfurman gregfurman requested a review from tiurin June 23, 2025 13:56
@gregfurman gregfurman marked this pull request as ready for review June 23, 2025 13:58
Copy link
Contributor

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

Question: should we actually accept the behavior, or fail when there are args? The signature of SkipSnapshotVerifyMarker is pretty clear, it only accepts keyword-only argument:

class SkipSnapshotVerifyMarker:
    def __call__(
        self,
        *,
        paths: "Optional[List[str]]" = None,
        condition: "Optional[Callable[[...], bool]]" = None,
    ): ...

See https://thepythoncodingbook.com/2022/12/11/positional-only-and-keyword-only-arguments-in-python/ and https://peps.python.org/pep-3102/

This PR goes a bit against that. I'd maybe suggest that we raise an exception if we pass an positional argument to the function, or maybe at least log a warning message as a first iteration to then raise an exception in a second one.

If we were to challenge this and change the behavior to accept positional arguments, we should also change the signature of the marker then.
Pretty cool tricks to extract the args though 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants