Closed ghost closed 2 years ago
Hi @Ascii67 ,
Thanks a lot for reporting this :bug: We're working on a fix.
I managed to reproduce this :bug: for classes that have a multiline docstring. Did you observe it in other scenarios as well?
The 2 cases I've found so far:
Case A) There's an empty line between the class definition and the docstring => This empty line gets underlined.
class Example:
"""
Example class to reproduce the bug.
https://github.com/sourcery-ai/sourcery/issues/272
"""
def placeholder(self):
print("anything")
Case B) No empty line between the class definition and the docstring, but an empty line between the docstring and the 1st method => The empty line between the docstring and the 1st method gets underlined.
class Example:
"""
Example class to reproduce the bug.
https://github.com/sourcery-ai/sourcery/issues/272
"""
def placeholder(self):
print("anything")
We're glad to hear that you're creating custom rules. :smiley: Do you have some feedback for us about them (besides this :bug:)?
For detecting calls to print
in production code, another possibility is:
pattern: print(...)
This flags only calls to print
, but doesn't flag other occurrences of print
, e.g.:
alias_for_print = print
See also the Flag print
Statements recipe in our docs.
Thanks for your answer, @reka!
I managed to reproduce this bug for classes that have a multiline docstring. Did you observe it in other scenarios as well?
No, I just observed this in scenarios where I have a class with a multiline docstring with this structure:
class ClassName:
"""
This is the docstring.
"""
def __init__(self) -> None:
...
Do you have some feedback for us about them (besides this bug)?
Since I've only just started with custom rules, I don't have any feedback yet but I didn't encounter any problems regarding custom rules and had a great experience with it!
Should be resolved with release of 0.12.8 - let us know if there are cases which aren't.
Checklist
Description
I added a custom rule in .sourcery.yaml which looks like this:
When I now start VSCode, the squiggly blue line is underneath the
print
statement. But when I now save the file, the squiggly blue line is right after the class definition:Debug Information
IDE Version: VSCode 1.71.0
Sourcery Version: 0.12.7
Operating system and Version: Ubuntu 22.04