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

code/source: some cleanups #7438

Merged
merged 13 commits into from
Jul 4, 2020
Merged

Commits on Jul 1, 2020

  1. code/source: expose deindent kwarg in signature

    Probably was done to avoid the shadowing issue, but work around it
    instead.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    2fe1784 View commit details
    Browse the repository at this point in the history
  2. code/source: remove Source(deindent: bool) parameter

    Not used, except in tests.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    4108174 View commit details
    Browse the repository at this point in the history
  3. code/source: remove old IndentationError workaround in getsource()

    This has been there since as far as the git history goes (2007), is not
    covered by any test, and says "Buggy python version consider upgrading".
    Hopefully everyone have upgraded...
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    c6083ab View commit details
    Browse the repository at this point in the history
  4. code/source: remove unneeded assert

    inspect.getsource() definitely returns str.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    c83e16a View commit details
    Browse the repository at this point in the history
  5. code/source: remove support for passing multiple parts to Source

    It isn't used, so keep it simple.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    2b99bfb View commit details
    Browse the repository at this point in the history
  6. code/source: remove support for comparing Source with str

    Cross-type comparisons like this are a bad idea. This isn't used.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    a127a22 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    a7303b5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    4a27d7d View commit details
    Browse the repository at this point in the history
  9. skipping: use plain compile() instead of _pytest._code.compile()

    eval() is used for evaluating string conditions in skipif/xfail e.g.
    
        @pytest.mark.skipif("1 == 0")
    
    This is the only code that uses `_pytest._code.compile()`, so removing
    its last use enables us to remove it entirely.
    
    In this case it doesn't add much. Plain compile() gives a good enough
    error message.
    
    For regular exceptions, the message is the same.
    
    For SyntaxError exceptions, e.g. "1 ==", the previous code adds a little
    bit of useful context:
    
    ```
    invalid syntax (skipping.py:108>, line 1)
    
    The above exception was the direct cause of the following exception:
    1 ==
         ^
    (code was compiled probably from here: <0-codegen /pytest/src/_pytest/skipping.py:108>) (line 1)
    
    During handling of the above exception, another exception occurred:
    Error evaluating 'skipif' condition
        1 ==
             ^
    SyntaxError: invalid syntax
    ```
    
    The new code loses it:
    
    ```
    unexpected EOF while parsing (<skipif condition>, line 1)
    
    During handling of the above exception, another exception occurred:
    Error evaluating 'skipif' condition
        1 ==
            ^
    SyntaxError: invalid syntax
    ```
    
    Since the old message is a minor improvement to an unlikely error
    condition in a deprecated feature, I think it is not worth all the code
    that it requires.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    9640c9c View commit details
    Browse the repository at this point in the history
  10. code/source: remove compiling functions

    A lot of complex code that isn't used anymore outside of tests after
    the previous commit.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    ef39115 View commit details
    Browse the repository at this point in the history
  11. code/source: inline getsource()

    The recursive way in which Source and getsource interact is a bit
    confusing, just inline it.
    bluetech committed Jul 1, 2020
    Configuration menu
    Copy the full SHA
    f5c69f3 View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2020

  1. Configuration menu
    Copy the full SHA
    40301ef View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    11efe05 View commit details
    Browse the repository at this point in the history