Skip to content

Update FilterType to retuning bool#9514

Merged
srittau merged 1 commit intopython:mainfrom
KalleDK:patch-2
Jan 16, 2023
Merged

Update FilterType to retuning bool#9514
srittau merged 1 commit intopython:mainfrom
KalleDK:patch-2

Conversation

@KalleDK
Copy link
Copy Markdown
Contributor

@KalleDK KalleDK commented Jan 12, 2023

The default Filter returns a bool and not an int

Closes #5700

The default Filter returns a bool and not an int
@KalleDK KalleDK changed the title Update __init__.pyi Update FilterType to retuning bool Jan 12, 2023
@github-actions
Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

core (https://github.com/home-assistant/core)
+ homeassistant/components/zha/core/gateway.py:505: error: Argument 1 to "addFilter" of "Filterer" has incompatible type "Union[Filter, Callable[[LogRecord], int]]"; expected "Union[Filter, Callable[[LogRecord], bool]]"  [arg-type]
+ homeassistant/components/zha/core/gateway.py:520: error: Argument 1 to "removeFilter" of "Filterer" has incompatible type "Union[Filter, Callable[[LogRecord], int]]"; expected "Union[Filter, Callable[[LogRecord], bool]]"  [arg-type]

Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like homeassistant just copied their type alias from the typeshed stub: https://github.com/home-assistant/core/blob/2ca73be9d0f02a00d65c9b05e7df5e06318adaff/homeassistant/components/zha/core/gateway.py#L94. So I think they'll just need to update thier type alias; I don't think they're actually passing callables that return int to this function.

Having said that, I'll leave this open in case any other maintainers have any thoughts, since the benefits also seem a little slim.

@srittau srittau merged commit 6b23df3 into python:main Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logging.Logger.addFilter

3 participants