Python's async functions (declared with "async def" rather than "def")
were not being displayed in hunk headers. This commit teaches git about
the async function syntax, and adds tests for the Python userdiff regex.
Signed-off-by: Josh Holland <anowlcalledjosh@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
--- /dev/null
+async def RIGHT(pi: int = 3.14):
+ while True:
+ break
+ return ChangeMe()
--- /dev/null
+class RIGHT(int, str):
+ # comment
+ # another comment
+ # ChangeMe
--- /dev/null
+def RIGHT(pi: int = 3.14):
+ while True:
+ break
+ return ChangeMe()
--- /dev/null
+class Foo:
+ async def RIGHT(self, x: int):
+ return [
+ 1,
+ 2,
+ ChangeMe,
+ ]
--- /dev/null
+if TYPE_CHECKING:
+ class RIGHT:
+ # comment
+ # another comment
+ # ChangeMe
--- /dev/null
+class Foo:
+ def RIGHT(self, x: int):
+ return [
+ 1,
+ 2,
+ ChangeMe,
+ ]
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
"|[-+*/<>%&^|=!.]=|--|\\+\\+|<<=?|>>=?|===|&&|\\|\\||::|->"),
-PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$",
+PATTERNS("python", "^[ \t]*((class|(async[ \t]+)?def)[ \t].*)$",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"