Hacker News new | past | comments | ask | show | jobs | submit login
How Does Git Know What a Python Function/Class Definition Looks Like? (twitter.com/simonw)
34 points by gilad on June 22, 2020 | hide | past | favorite | 5 comments



I really like the "TIL" format. I tweeted this a few weeks ago and it seemed to have really resonated with people.


Very thin content. There were really only two options: regex or parser. This is close to "You won't believe what happened next" level of content.


So uhm, what happens if someone puts class Datasette: in a multiline string?


The regex has a clause to cover that case?


It doesn't.

And I finally took the time to test it; git does the wrong thing.

Idk if it's display only (in which case I guess a 99.99% solution is fine), or if it's actually used somehow say when applying a patch, in which case it may lead to security issues.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: