Skip to content

Commit

Permalink
Compute abspath once
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Oct 18, 2020
1 parent c47300b commit b511aea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@ class State:
order = None # type: int # Order in which modules were encountered
id = None # type: str # Fully qualified module name
path = None # type: Optional[str] # Path to module source
abspath = None # type: Optional[str] # Absolute path to module source
xpath = None # type: str # Path or '<string>'
source = None # type: Optional[str] # Module source code
source_hash = None # type: Optional[str] # Hash calculated based on the source code
Expand Down Expand Up @@ -1800,6 +1801,8 @@ def __init__(self,
if follow_imports == 'silent':
self.ignore_all = True
self.path = path
if path:
self.abspath = os.path.abspath(path)
self.xpath = path or '<string>'
if path and source is None and self.manager.fscache.isdir(path):
source = ''
Expand Down Expand Up @@ -2758,7 +2761,7 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,

# Note: Running this each time could be slow in the daemon. If it's a problem, we
# can do more work to maintain this incrementally.
seen_files = {os.path.abspath(st.path): st for st in graph.values() if st.path}
seen_files = {st.abspath: st for st in graph.values() if st.path}

# Collect dependencies. We go breadth-first.
# More nodes might get added to new as we go, but that's fine.
Expand Down

0 comments on commit b511aea

Please sign in to comment.