Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in Filters #3272

Closed

Conversation

rglsk
Copy link
Contributor

@rglsk rglsk commented Oct 1, 2022

Refer to #3109, done:

  • Updated method and class docstring to follow the same convention (start with new line)
  • Fix couple of typos
  • Fix typing override issue with check_update method (@Bibo-Joshi : Please let me know if this change should be cherry-picked to other branch to merge across master -> I'm happy to do if if the proposed suggestion fits you 😄 )

Checklist for PRs

  • Added .. versionadded:: version, .. versionchanged:: version or .. deprecated:: version to the docstrings for user facing changes (for methods/class descriptions, arguments and attributes)
  • Created new or adapted existing unit tests
  • Documented code changes according to the CSI standard
  • Added myself alphabetically to AUTHORS.rst (optional)
  • Added new classes & modules to the docs and all suitable __all__ s

@@ -182,8 +183,16 @@ def __init__(self, name: str = None, data_filter: bool = False):
self._name = self.__class__.__name__ if name is None else name
self._data_filter = data_filter

def check_update(self, update: Update) -> Optional[Union[bool, DataDict]]: # skipcq: PYL-R0201
"""Checks if the specified update is a message."""
def check_update(self, update: Update) -> bool: # skipcq: PYL-R0201
Copy link
Member

Choose a reason for hiding this comment

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

the type hint change should be reverted. The subclasses of BaseFilters check_update can return DataDict based on data_filter property. That's why pylint also complained in UpdateFilter and MessageFilter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@harshil21 Are you sure? the base method can only return the True of False 🤔 The methods which overrides this one can return the DataDict 🤔
Screenshot 2022-10-01 at 16 21 31

Copy link
Member

Choose a reason for hiding this comment

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

imo, base method should have same sig as children (if possible). Let's see what others think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@harshil21 I reverted the change for now, we can do it in another PR to get others opinions on this specific case later 👍

Copy link
Member

Choose a reason for hiding this comment

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

I agree with harshil here.

telegram/ext/filters.py Outdated Show resolved Hide resolved
@harshil21 harshil21 changed the title 3109 update ext filters Fix typos in Filters Oct 1, 2022
@harshil21 harshil21 added this to the v20.0a5 milestone Oct 1, 2022
There was an issue that base method returned only bool but typing was
saying something else just to match pylint override error.
…ntion.

Most of the code bases there is convention to start docstring with a new
line.
Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

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

let's also wait for other reviews. And, please avoid force pushing since it makes it harder to review

telegram/ext/filters.py Outdated Show resolved Hide resolved
telegram/ext/filters.py Outdated Show resolved Hide resolved
update (:class:`telegram.Update`): Incoming update.

Returns:
:obj:`bool` | Dict[str, list]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:obj:`bool` | Dict[str, list]
:obj:`bool` | Dict[:obj:`str`, :obj:`list`]

Comment on lines +119 to +120
"""
Base class for all Filters.
Copy link
Member

Choose a reason for hiding this comment

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

TBH I don't really see any value in these changes - in this PR or even at all, that is.
True, some style guides suggest to start the docstring on a new line, but none of the styling tools that we currently use will report on these things. If we want to have docstrings start on a new line, I would rather like to make it a standalone issue to apply this to the whole code base.
I'm inclined to ask to revert these changes. Let's first hear what others think, though.

Copy link
Member

Choose a reason for hiding this comment

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

I also agree to revert, they are rendered the same and PEP 257 does not comment on this design.

@Bibo-Joshi
Copy link
Member

PS: you mentioned #3109 in all your PRs so far - I'd like to point out that none of your PRs addressed #3109 in any way 😉

@rglsk
Copy link
Contributor Author

rglsk commented Oct 1, 2022

Alright folks, sorry for that, I'll try better next time 🙏

@rglsk rglsk closed this Oct 1, 2022
@harshil21 harshil21 removed this from the v20.0a5 milestone Oct 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants