Skip to content

gh-134861: Add CSV and 🍌SV output formats to asyncio ps #134862

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dpdani
Copy link
Contributor

@dpdani dpdani commented May 28, 2025

# Conflicts:
#	Lib/asyncio/tools.py
@ZeroIntensity
Copy link
Member

(Skipping news because this is an easter egg)

@johnzhou721
Copy link
Contributor

@ZeroIntensity Hmm... But isn't the CSV format legit, so in my (very bad) opinion it still need news?

@ZeroIntensity
Copy link
Member

Oh, hm. I guess we could add an entry for only CSV. I'll leave the decision to @dpdani.

class TaskTableOutputFormat(Enum):
table = "table"
csv = "csv"
bsv = "bsv"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps for the Easter Egg, make the argument the literal banana emoji, 'bsv' is too generic. Please also add some sort of reference for the future in a comment as to why bananas are relevant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danielhollas I would agree to change the argument to 🍌 sv. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copying my comment from #134862 (comment)

This would print the 🍌sv option in the argparse help, right? Is that desired? (I don't care about hiding it, but I think it could be very confusing for users, and also may display weirdly if they don't have a proper font installed).

Don't have a strong opinion 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @danielhollas, I agree. @dpdani please hide this from the argparse help (in whatever form the argument ends up being; '🍌' / '🍌sv' / 'bsv')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mm that wouldn't be trivial, considering that argparse would error out because the format is not in the list.
Does it really have to be hidden?

Copy link
Contributor

Choose a reason for hiding this comment

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

My proposal: Instead of doing --format, do another option --banana that is only in effect when --format csv is used but does not error out when it isn't so it make the easter egg harder to discover. We can use https://stackoverflow.com/questions/37303960/show-hidden-option-using-argparse on that, and have a _banana boolean for it to set, that way we can use elif == <...>.csv (explicit > implicit) on L224 and simplify L240 a lot by simply using a boolean for checking banana and not a switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels very hacky to do it though, I'm not sure.
Right now I'm leaning on the current behavior:

$ ./python.exe -m asyncio ps --help                     
usage: python3 -m asyncio ps [-h] [--format {table,csv,bsv}] pid

positional arguments:
  pid                   Process ID to inspect

options:
  -h, --help            show this help message and exit
  --format {table,csv,bsv}

$ ./python.exe -m asyncio ps 92294 --format bsv
tid🍌task id🍌task name🍌coroutine chain🍌awaiter name🍌awaiter id
4876371🍌0x101c4bdf0🍌Task-4🍌🍌🍌0x0

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep... but bsv is too generic. We want to be hacky, the hackier the harder for users to find and the greater joy it brings to the Python community.

@AA-Turner
Copy link
Member

@ZeroIntensity Hmm... But isn't the CSV format legit, so in my (very bad) opinion it still need news?

Yes, please add news for CSV format

Copy link
Contributor

@johnzhou721 johnzhou721 left a comment

Choose a reason for hiding this comment

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

Yep, agreed with the NEWS part. But might it make the Easter Egg too obvious? Since people can just look at the PR through news. I think we might be able to split up the PRs into CSV and BSV and skip news on the latter, but it might be too much work.

class TaskTableOutputFormat(Enum):
table = "table"
csv = "csv"
bsv = "bsv"
Copy link
Contributor

Choose a reason for hiding this comment

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

@AA-Turner
Copy link
Member

AA-Turner commented May 29, 2025

Yep, agreed with the NEWS part. But might it make the Easter Egg too obvious? Since people can just look at the PR through news. I think we might be able to split up the PRs into CSV and BSV and skip news on the latter, but it might be too much work.

We're not trying to hide or obsfucate; just not to advertise.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@python-cla-bot
Copy link

python-cla-bot bot commented May 29, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@johnzhou721
Copy link
Contributor

johnzhou721 commented May 29, 2025 via email

Copy link
Contributor

@johnzhou721 johnzhou721 left a comment

Choose a reason for hiding this comment

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

Another suggestion to make this easier to impl and harder to discover.

class TaskTableOutputFormat(Enum):
table = "table"
csv = "csv"
bsv = "bsv"
Copy link
Contributor

Choose a reason for hiding this comment

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

My proposal: Instead of doing --format, do another option --banana that is only in effect when --format csv is used but does not error out when it isn't so it make the easter egg harder to discover. We can use https://stackoverflow.com/questions/37303960/show-hidden-option-using-argparse on that, and have a _banana boolean for it to set, that way we can use elif == <...>.csv (explicit > implicit) on L224 and simplify L240 a lot by simply using a boolean for checking banana and not a switch.

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.

6 participants