Enable static type checking with pytype (#298)
* Ignore pytype import errors in google/auth.
These errors are raised because the packages are not required, i.e. not
listed in setup.py. We can't guarantee they'll be installed or that
their pyi files exist in github.com/python/typeshed, so silence
potential errors instead.
This does impact the accuracy of type checking.
* Ignore pytype import errors in transport/.
These imports are not listed in setup.py, because they are optional --
it is assumed the user has them installed if needed. Disabling
import-error for these imports prevents useless errors from pytype.
* Ignore various type errors raised by pytype.
- `__init__.py`: pytype is not aware of `__path__`.
- jwt.py: the pyi file for urllib.unparse is not aware of None. Empty
strings are clearer.
* Add pytype disable comments for scripts/
oauth2client isn't listed as a requirement, so users may not have it
installed.
* Fix lint errors from pytype directives.
* Enable pytype -V3.6.
A few notes:
- Previous commits fixed type errors detected by pytype.
- setup.cfg disables pytype's `pyi-error`. This is necessary due to
incomplete type stubs in https://github.com/python/typeshed.
- This only enables pytype's Python3.6 checks. Python2.7 is supported by
pytype but incomplete type stubs cause spurious type errors.
* Remove pytype directives.
Updates to pytype made these directives unnecessary.
* Move pytype install command.
* Add pytype to tox.
* Remove pytype directives for tox-installed imports.
These imports are handled by setup.py and tox.ini, so they'll be
available when pytype is run under tox.
* Fix lint error.
diff --git a/google/auth/jwt.py b/google/auth/jwt.py
index ef23db2..3805f37 100644
--- a/google/auth/jwt.py
+++ b/google/auth/jwt.py
@@ -738,7 +738,7 @@
parts = urllib.parse.urlsplit(url)
# Strip query string and fragment
audience = urllib.parse.urlunsplit(
- (parts.scheme, parts.netloc, parts.path, None, None))
+ (parts.scheme, parts.netloc, parts.path, "", ""))
token = self._get_jwt_for_audience(audience)
self.apply(headers, token=token)