Skip to content

Commit

Permalink
add stacklevel to warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Aug 25, 2023
1 parent e3b66b1 commit 92c0c77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ahk/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ def register(self, ext: Extension, f: Callable[P, T]) -> Callable[P, T]:
warnings.warn(
f'Method of name {f.__name__!r} has already been registered. '
f'Previously registered method {self.async_methods[f.__name__].method!r} '
f'will be overridden by {f!r}'
f'will be overridden by {f!r}',
stacklevel=2,
)
self.async_methods[f.__name__] = _ExtensionEntry(extension=ext, method=f)
else:
if f.__name__ in self.sync_methods:
warnings.warn(
f'Method of name {f.__name__!r} has already been registered. '
f'Previously registered method {self.sync_methods[f.__name__].method!r} '
f'will be overridden by {f!r}'
f'will be overridden by {f!r}',
stacklevel=2,
)
self.sync_methods[f.__name__] = _ExtensionEntry(extension=ext, method=f)
return f
Expand Down

0 comments on commit 92c0c77

Please sign in to comment.