Skip to content

Commit 6f4f39a

Browse files
Fabian Schenkmeta-codesync[bot]
authored andcommitted
Annotate g_pathmgr global type and fix surfaced caller
Summary: Splits the one behavior-visible piece out of the `file_io.py` type-annotation reland (D110187182) into its own base diff. Annotates the module-level `g_pathmgr` global with its concrete type: g_pathmgr: PathManager = PathManagerFactory.get(defaults_setup=True) replacing the `# pyre-fixme[5]: Global expression must be annotated.` suppression. This is the only change in the reland with a downstream blast radius: an un-annotated global that trips `[5]` is exported to *other* modules as `Any`, which silences all attribute/argument checks on `g_pathmgr` at every call site. Giving it a real type binds `g_pathmgr.open(...)` to the actual `PathManager.open(path: str, ...)` signature, so pyre now type-checks its arguments in downstream projects. That surfaces one pre-existing latent error in `oculus/face`: benchmark_visualize.py:229 Incompatible parameter type [6]: for 1st positional argument, expected `str` but got `Optional[str]`. `meta.uri` is `Optional[str]` and was being passed straight into `open`, previously masked because `g_pathmgr` was `Any`. Narrowed with an `assert meta.uri is not None` immediately before the call. It sits inside the existing surrounding `try`/`except`, so a `None` uri raises `AssertionError` and is swallowed exactly as `open(None)` would have been — no runtime behavior change, and no new import. Keeping this at the base of the stack makes every commit independently type-clean (important for bisect); the mechanical, blast-radius-free annotation modernization stays isolated in D110187182 on top. ___ Differential Revision: D110314532 fbshipit-source-id: cbbb4bb69e975f7c2b441c377ce4b4c0577ccae6
1 parent a20cd1b commit 6f4f39a

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

iopath/common/file_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,5 +1761,4 @@ def remove(key):
17611761
This global instance is provided for backward compatibility, but it is
17621762
recommended that clients use PathManagerFactory
17631763
"""
1764-
# pyre-fixme[5]: Global expression must be annotated.
1765-
g_pathmgr = PathManagerFactory.get(defaults_setup=True)
1764+
g_pathmgr: PathManager = PathManagerFactory.get(defaults_setup=True)

0 commit comments

Comments
 (0)