-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add __repr__ methods for selected classes
#3826
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
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
37dccdc
add `__repr__` to `Application`
lemontree210 ca0a991
add `__repr__` to `CallbackContext`
lemontree210 2263820
add `__repr__` to `Bot` and `ExtBot`
lemontree210 6e6b9b6
add `__repr__` to `Job`
lemontree210 30f075d
add `__repr__` for `JobQueue`
lemontree210 2b60955
Merge branch 'master' into repr-for-classes-3770
lemontree210 3051620
move `__repr__` in `Job` up in code with no change
lemontree210 0da0efc
add `.job.trigger` to `Job.__repr__()`
lemontree210 edd551c
add __repr__ to `Updater`
lemontree210 1f5bbd6
add __repr__ to `BaseHandler`
lemontree210 43d93e3
add __repr__ to `ConversationHandler`
lemontree210 867762d
use `__qualname__` for callback in `BaseHandler`
lemontree210 9c2a9c3
add auxiliary function and try building `Application.__repr__` with it
lemontree210 ef396ac
replace parentheses with square brackets
lemontree210 8c83c69
replace `__repr__` in `CCT`, `Bot`, `ExtBot`, `Job`, `JobQueue`
lemontree210 600022d
replace `__repr__` in `BaseHandler`
lemontree210 4d16fba
replace `__repr__` in `Updater`, remove queue size
lemontree210 ef50a0f
replace `__repr__` in `ConversationHandler`, show truncated list of s…
lemontree210 275009b
Merge remote-tracking branch 'origin/master' into repr-for-classes-3770
lemontree210 cddaba8
add tests for `Application`, `Bot`, `CallbackContext`
lemontree210 8b2a573
add test for `Job` and `JobQueue`
lemontree210 76c2ad7
add test for __repr__ in `TypeHandler`
lemontree210 def0508
add ellipsis to ConversationHandler.__repr__, add test
lemontree210 886ebf1
add test for `Updater`
lemontree210 0aa874b
move test for `__repr__` from test_typehandler.py to test_basehandler.py
lemontree210 6f75015
set explicit `when=` for test of `JobQueue.__repr__`
lemontree210 61714ea
remove `__repr__` from `CallbackContext`
lemontree210 38c2daa
Merge remote-tracking branch 'origin/master' into repr-for-classes-3770
lemontree210 101bb1b
refactor: move `_stringify()` outside of func
lemontree210 0a93e44
amend comment
lemontree210 40c7940
fix deepsource issue
lemontree210 07023df
add test for `ConversationHandler`
lemontree210 69e8652
use `app` fixture in test instead of instantiating new app
lemontree210 07bb191
remove unnecessary import
lemontree210 40e1c0f
introduce dict-like repr of states in ConversationHandler
lemontree210 ca2b6a3
Merge branch 'master' into repr-for-classes-3770
lemontree210 68936d6
Merge branch 'master' into repr-for-classes-3770
lemontree210 161f2b5
fix docstring of `build_repr...`
lemontree210 91ff99a
add docstring for `Application.__repr__()`
lemontree210 fb37210
add docstring for `Bot.__repr__()` and `ExtBot.__repr__()`
lemontree210 9f3ebee
add docstring for `Job.__repr__()` and `JobQueue.__repr__()`
lemontree210 add9159
add docstring for `Updater.__repr__()`
lemontree210 b450579
add docstring for `BaseHandler.__repr__()`
lemontree210 1b311d5
add docstring for `ConversationHandler.__repr__()`
lemontree210 2be38b1
remove warning since fixture is used in test
lemontree210 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # A library that provides a Python interface to the Telegram Bot API | ||
| # Copyright (C) 2015-2023 | ||
| # Leandro Toledo de Souza <devs@python-telegram-bot.org> | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU Lesser Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser Public License | ||
| # along with this program. If not, see [http://www.gnu.org/licenses/]. | ||
| """This module contains auxiliary functionality for building strings for __repr__ method. | ||
|
|
||
| Warning: | ||
| Contents of this module are intended to be used internally by the library and *not* by the | ||
| user. Changes to this module are not considered breaking changes and may not be documented in | ||
| the changelog. | ||
| """ | ||
| from typing import Any | ||
|
|
||
|
|
||
| def build_repr_with_selected_attrs(obj: object, **kwargs: Any) -> str: | ||
| """Create ``__repr__`` string in the style ``Classname[arg1=1, arg2=2]``. | ||
|
|
||
| The square brackets emphasize the fact that an object cannot be instantiated | ||
| from this string. | ||
|
|
||
| Attributes that are to be used in the representation, are passed as kwargs. | ||
| """ | ||
| return ( | ||
| f"{obj.__class__.__name__}" | ||
| # square brackets emphasize that an object cannot be instantiated with these params | ||
| f"[{', '.join(_stringify(name, value) for name, value in kwargs.items())}]" | ||
| ) | ||
|
|
||
|
|
||
| def _stringify(key: str, val: Any) -> str: | ||
| return f"{key}={val.__qualname__ if callable(val) else val}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, codecov complains that the (implicit)
elseclause here is not covered …Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed