Skip to content

Commit

Permalink
set default values for Codeowners
Browse files Browse the repository at this point in the history
  • Loading branch information
romainkomorndatadog committed Aug 29, 2024
1 parent 31fcdb8 commit a3a6b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ddtrace/internal/ci_visibility/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def set_codeowners_of(cls, location, span=None):
span.set_tag(test.CODEOWNERS, json.dumps(handles))
else:
log.debug("no matching codeowners for %s", location)
except KeyError:
except: # noqa: E722
log.debug("Error setting codeowners for %s", location, exc_info=True)

@classmethod
Expand Down
10 changes: 8 additions & 2 deletions ddtrace/internal/codeowners.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@ def __init__(self, path: Optional[str] = None, cwd: Optional[str] = None):
:param path: path to CODEOWNERS file otherwise try to use any from known locations
"""
self.patterns: List[Tuple[re.Pattern, List[str]]] = []
self.path: Optional[str] = None

path = path or self.location(cwd)

if path is None:
raise ValueError("CODEOWNERS file not found")

self.path: str = path
self.patterns: List[Tuple[re.Pattern, List[str]]] = []
self.path = path
self.parse()

def location(self, cwd: Optional[str] = None) -> Optional[str]:
Expand All @@ -142,6 +145,9 @@ def location(self, cwd: Optional[str] = None) -> Optional[str]:

def parse(self) -> None:
"""Parse CODEOWNERS file and store the lines and regexes."""
if self.path is None:
return

with open(self.path) as f:
patterns = []
for line in f.readlines():
Expand Down

0 comments on commit a3a6b2f

Please sign in to comment.