FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-46752: Uniform TaskGroup.__repr__ by asvetlov · Pull Request #31409 · python/cpython · GitHub

/ cpython Public

bpo-46752: Uniform TaskGroup.__repr__ - #31409

Merged
asvetlov merged 3 commits into
mainfrom
taskgroup-repr
Feb 20, 2022
Merged

bpo-46752: Uniform TaskGroup.__repr__#31409
asvetlov merged 3 commits into
mainfrom
taskgroup-repr

Conversation

asvetlov commented Feb 18, 2022
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Other asyncio objects use prop=val format, not prop:val.

https://bugs.python.org/issue46752

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Didn't you say other asyncio objects use prop=val? Were you going to add that? (I guess it'll require updating a few tests.)

Comment thread Lib/asyncio/taskgroups.py Outdated
Comment on lines +41 to +42
info_str = ' ' + ' '.join(info)
return f'<TaskGroup{info_str}>'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
info_str = ' ' + ' '.join(info)
return f'<TaskGroup{info_str}>'
info_str = ' '.join(info)
return f'<TaskGroup {info_str}>'

asvetlov Feb 18, 2022
edited by gvanrossum
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

After applying the suggestion, a repr for created TaskGroup before __enter__() is called will be "<TaskGroup >" (note the space after class name).
Is it ok? Should we care about this rare case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

IMO accumulating strings in [] isn't a great pattern unless you have to use it for performance reasons. /my2c.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

After applying the suggestion, a repr for created TaskGroup before __enter__() is called will be "<TaskGroup >" (note the space after class name). Is it ok? Should we care about this rare case?

The original code has the same issue AFAICT. If you don't want that you could initialize info = [''] perhaps?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

IMO accumulating strings in [] isn't a great pattern unless you have to use it for performance reasons. /my2c.

Meh. IIRC the info pattern is used all over asyncio (e.g. _task_repr_info in base_tasks.py).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

info = [''] is clever, applied.

Yes, info list is used by other asyncio repr's. I'd like to have the similar approach across the library.

Copy link
Copy Markdown
Contributor Author

Oops, I've mentioned the problem ': vs =' problem but didn't actually resolve it.
Fixed. I'm sorry. Now = is used.

Copy link
Copy Markdown
Contributor Author

@gvanrossum do you want tests for __repr__?
I'm lazy but can write them on demand.

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No need for tests. Maybe a new contributor will add them. :-)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL