Skip to content

Commit

Permalink
feat: railsignore - finalizing review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanitshimanga committed Oct 18, 2024
1 parent 11b7292 commit e41821e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nemoguardrails/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def get_railsignore_path(path: Optional[str] = None) -> Optional[Path]:
return None


def get_railsignore_patterns(railsignore_path) -> Set[str]:
def get_railsignore_patterns(railsignore_path: Path) -> Set[str]:
"""
Helper to retrieve all specified patterns in railsignore.
Returns:
Expand All @@ -352,8 +352,6 @@ def get_railsignore_patterns(railsignore_path) -> Set[str]:
if railsignore_path is None:
return ignored_patterns

# railsignore_path = get_railsignore_path()

# File doesn't exist or is empty
if not railsignore_path.exists() or not os.path.getsize(railsignore_path):
return ignored_patterns
Expand All @@ -377,13 +375,13 @@ def get_railsignore_patterns(railsignore_path) -> Set[str]:
return ignored_patterns


def is_ignored_by_railsignore(filename, ignore_patterns) -> bool:
def is_ignored_by_railsignore(filename: str, ignore_patterns: str) -> bool:
"""Helper to verify if a filename should be ignored by a railsignore pattern"""
ignore = False

# Load candidate patterns from railsignore

for pattern in ignore_patterns:
if fnmatch.fnmatch(filename, pattern):
ignore = True
break

return ignore

0 comments on commit e41821e

Please sign in to comment.