Skip to content

Commit

Permalink
Dict key lookup for performance increase
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Bauer <[email protected]>
  • Loading branch information
bimtauer committed Apr 5, 2022
1 parent b268181 commit c52062a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flytekit/tools/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fnmatch import fnmatch
from pathlib import Path
from shutil import which
from typing import List, Optional
from typing import Dict, List, Optional

from docker.utils.build import PatternMatcher

Expand Down Expand Up @@ -43,15 +43,15 @@ def __init__(self, root: Path):
self.has_git = which("git") is not None
self.ignored = self._list_ignored()

def _list_ignored(self) -> List[str]:
def _list_ignored(self) -> Dict:
if self.has_git:
out = subprocess.run(["git", "ls-files", "-io", "--exclude-standard"], cwd=self.root, capture_output=True)
if out.returncode == 0:
return out.stdout.decode("utf-8").split("\n")[:-1]
return dict.fromkeys(out.stdout.decode("utf-8").split("\n")[:-1])
cli_logger.warning(f"Could not determine ignored files due to:\n{out.stderr}\nNot applying any filters")
return []
return {}
cli_logger.info("No git executable found, not applying any filters")
return []
return {}

def _is_ignored(self, path: str) -> bool:
if self.ignored:
Expand Down

0 comments on commit c52062a

Please sign in to comment.