Your regular expression is quoted with single quotes, but it also contains a single quote.
The single quote in ["'] needs to be escaped, or it will signal the end of the quoted string to the shell.
This will fix it:
grep -r -P -o -h '(?<=(?<!def )my_method )(["'\''])(?:(?=(\\?))\2.)*?\1'
# ^^^^
With ["'\''], the first ' ends the first part of the string, the \' inserts a literal single quote, and the last ' starts a new single quoted string that will be concatenated with the previous bits. Only the middle single quote will end up in the regular expression itself, the other two will be removed by the shell.