Eric, pytype still emits an error for a TypeVar that appears only once in a function signature.

If it helps, misunderstandings I've seen a lot are:
BaseClassVar = TypeVar("BaseClassVar", bound=BaseClass)
def f(x: BaseClassVar): ...  # the intention is that this means "a subclass of BaseClass but not BaseClass itself". I still have not figured out where this idea came from.
Best,
Rebecca

On Sat, Dec 12, 2020 at 7:45 AM Guido van Rossum <guido@python.org> wrote:
Interesting. Can you give (or link to) some examples of the misunderstandings? I’d like to understand what might lead them to that (other than cargo-culting).

On Fri, Dec 11, 2020 at 22:27 Eric Traut <eric@traut.com> wrote:
I apologize for reopening this discussion, but I'm considering reversing our earlier decision and adding an error (or at least a warning) in pyright for a TypeVar that appears only once in a function signature.

We continue to receive a stream of bug reports filed against pyright that are actually bugs in the user's code based on misuse (and a misunderstanding) of TypeVars in generic functions. Most of these misunderstandings could be avoided if we introduction an error message in this case.

Rebecca, I'm curious what decision you made for pytype. Does it still emit an error in this case, or did you decide to remove the check based on this discussion?

-Eric

--
Eric Traut
Contributor to pyright & pylance
Microsoft Corp.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: guido@python.org
--
--Guido (mobile)
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: rechen@google.com