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

Update monkeypatch to fix (many) line numbers being off due to decorators #86

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

JamesHutchison
Copy link
Owner

@JamesHutchison JamesHutchison commented Apr 18, 2024

This is a bit of a complicated problem and is not fully resolved, but this seems to be improvement over the simple adjustment in the previous logic. The old logic was doing a simple shift on the line numbers, and it seemed to fix the problem if a function was lower in the file after a function that had a single decorator.

For example:

@pytest.fixture(autouse=True)
def setup(self):
    ...

def function_with_wrong_line_numbers(self):
    # the off by one fix in the previous code fixed me

In all other cases the line numbers would be wrong. With this new fix, I'm seeing most cases being correct except for multiline decorators, but it's easily fixed by altering the function with the wrong line numbers.

@somedecorator(

)
def this_function_will_offset_line_numbers_by_2(...):
    ...

See breuleux/jurigged#29 for the full issue discussion.

@JamesHutchison JamesHutchison merged commit 6ee3cc3 into main Apr 18, 2024
3 checks passed
@JamesHutchison JamesHutchison deleted the update-monkeypatch-jurigged-decorators branch April 18, 2024 03:42
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.

1 participant