Repository: google/pytype

Issue:
AssertionError: Don't know how to match <class 'pytype.pytd.pytd.Name…
…dType'> against <class 'pytype.pytd.pytd.Literal'>

I opened an issue for this error. If this a possible fix for this issue, feel free to merge the fix. 
Issue = https://github.com/google/pytype/issues/802


Discussion:

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here with `@googlebot I signed it!` and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](http://go/cla#troubleshoot) ([Public version](https://opensource.google/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

ℹ️ **Googlers: [Go here](https://goto.google.com/prinfo/https%3A%2F%2Fgithub.com%2Fgoogle%2Fpytype%2Fpull%2F803) for more info**.

<!-- need_sender_cla -->
Thanks for this PR! I wonder if there will eventually be cases where we want NamedType to match LiteralType, since we lose constant values when we convert to pytd, but fixing the crash seems like a step in the right direction regardless. As next steps, could you (1) sign the CLA, and (2) fix the indentation (pytype uses 2-space, rather than 4-space, indentation)?
@googlebot I signed it!
Signed the CLA and Fixed the indentation. Will wait for the nightly. Please let me know if anything else is needed. Thanks.
Thanks, I am a Mac user. The Mac OS specific errors in Pytype hurts me a lot. :)  

Resolving patch:
diff --git a/pytype/pytd/type_match.py b/pytype/pytd/type_match.py
--- a/pytype/pytd/type_match.py
+++ b/pytype/pytd/type_match.py
@@ -347,6 +347,8 @@ def _match_type_against_type(self, t1, t2, subst):
         return booleq.FALSE
       else:
         return booleq.Eq(t1.name, t2.name)
+    elif isinstance(t1, pytd.NamedType) and isinstance(t2, pytd.Literal):
+      return booleq.FALSE
     elif isinstance(t1, pytd.LateType) or isinstance(t2, pytd.LateType):
       # Unresolved types never match against anything.
       return booleq.FALSE


Test patch: