autoDocstring icon indicating copy to clipboard operation
autoDocstring copied to clipboard

Remove inline comments during line preprocessing

Open IniasP opened this issue 5 years ago • 5 comments

Looks like the current implementation only removes lines that start with "#" to filter comments. As described in issue #160, inline comments are missed. This should resolve issue #160.

IniasP avatar Oct 04 '20 21:10 IniasP

Thank you for opening this PR! Could you add a test to validate that the behavior is correct?

NilsJPWerner avatar Oct 08 '20 02:10 NilsJPWerner

Good thing you asked for a test case, turns out we missed something (see commit message on 100adc3). Should be good now.

IniasP avatar Oct 13 '20 13:10 IniasP

Sorry for the massive delay on responding to this. Does this handle strings that have the pound sign in them? e.g. x = "# abc"

NilsJPWerner avatar Mar 08 '21 04:03 NilsJPWerner

So we could possibly limit this to only trim comments in the docstring definition since it is less likely to have a string with a # in it than in the body.

NilsJPWerner avatar Mar 08 '21 05:03 NilsJPWerner

I don't think I realized at the time that hash symbols in strings are possible. I agree with the discussion at #144 that this will be impossible to do exactly right with regex, because it's fundamentally outside of the scope of regular languages. Also, this is really low impact so maybe this should just be a wontfix thing. Maybe there should be a test case addressing this specifically, because I did get all tests to pass.

IniasP avatar Mar 10 '21 10:03 IniasP