1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-08 18:02:05 +03:00

Fix flake8 with Python 2.7

Summary:
flake8 (in Python 2.7 mode) complains that `typing` is mentioned in type annotations but is not defined:

```
fbcode_builder/getdeps/buildopts.py:251:21: F821 undefined name 'typing'
    subst_mapping,  # type: typing.Mapping[str, str]
                    ^
fbcode_builder/getdeps/buildopts.py:253:5: F821 undefined name 'typing'
    # type: (...) -> typing.Optional[str]
    ^
2     F821 undefined name 'typing'
2
```

Import `typing` explicitly to silence this warning.

Because `typing` may be unavailable, import it conditionally. (Because it's only referenced in comments, failing to import `typing` should have no effect at run time.)

Reviewed By: snarkmaster

Differential Revision: D16435696

fbshipit-source-id: 78a4a7b07acc46aa998f02b54b1a6e52c1daafde
This commit is contained in:
Matt Glazar
2019-07-26 14:16:11 -07:00
committed by Facebook Github Bot
parent ee28489283
commit d68c526f65

View File

@@ -21,6 +21,12 @@ from .envfuncs import Env, add_path_entry, path_search
from .platform import HostType, is_windows
try:
import typing # noqa: F401
except ImportError:
pass
def containing_repo_type(path):
while True:
if os.path.exists(os.path.join(path, ".git")):