Skip to content
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

Failing lambda in source after upgrade #3851

Closed
eivindjahren opened this issue Jan 19, 2024 · 4 comments
Closed

Failing lambda in source after upgrade #3851

eivindjahren opened this issue Jan 19, 2024 · 4 comments

Comments

@eivindjahren
Copy link

After upgrading from 6.83.3 to 6.96.1 the following assert fails. I have been unable to find exactly the conditions that reproduce the failure.

    def extract_lambda_source(f):
        """Extracts a single lambda expression from the string source. Returns a
        string indicating an unknown body if it gets confused in any way.
    
        This is not a good function and I am sorry for it. Forgive me my
        sins, oh lord
        """
        # You might be wondering how a lambda can have a return-type annotation?
        # The answer is that we add this at runtime, in new_given_signature(),
        # and we do support strange choices as applying @given() to a lambda.
        sig = inspect.signature(f)
        assert sig.return_annotation in (inspect.Parameter.empty, None), sig
    
        if sig.parameters:
            if_confused = f"lambda {str(sig)[1:-1]}: <unknown>"
        else:
            if_confused = "lambda: <unknown>"
        try:
            source = inspect.getsource(f)
        except OSError:
            return if_confused
    
        source = LINE_CONTINUATION.sub(" ", source)
        source = WHITESPACE.sub(" ", source)
        source = source.strip()
        if "lambda" not in source and sys.platform == "emscripten":  # pragma: no cover
            return if_confused  # work around Pyodide bug in inspect.getsource()
>       assert "lambda" in source
@Zac-HD
Copy link
Member

Zac-HD commented Jan 19, 2024

Please provide a (preferably minimal) reproducing example so that we can try to debug this? You must have some command that triggers it.

Our test suite already has several variations which have continued working, and it'd be great to add yours so we can ensure that this gets fixed and doesn't happen again later.

@eivindjahren
Copy link
Author

I will try, but with the randomness involved it is difficult.

@Zac-HD
Copy link
Member

Zac-HD commented Jan 21, 2024

  • Sharing an example which sometimes reproduces is still more useful than not sharing an example
  • You can try passing --hypothesis-seed=0, 1, 2, 3... to reduce the influence of randomness

@Zac-HD
Copy link
Member

Zac-HD commented Jan 27, 2024

Closing this because I haven't been able to reproduce it.

@Zac-HD Zac-HD closed this as completed Jan 27, 2024
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

No branches or pull requests

2 participants