GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-113299: Move Argument Clinic CLI into libclinic by erlend-aasland · Pull Request #115542 · python/cpython

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Feb 15, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Refactor Argument Clinic support code into libclinic #113299

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AlexWaygood reacted with heart emoji
All reactions
  • ❤️ 1 reaction
AlexWaygood and others added 6 commits February 16, 2024 00:01
@AlexWaygood @erlend-aasland
Reorganise the Tools/clinic directory
f064435
@AlexWaygood @erlend-aasland
black Tools/clinic/libclinic/cli.py --line-length 90
1b423c1
@AlexWaygood @erlend-aasland
Add __all__
f2d2c86
@AlexWaygood @erlend-aasland
update PC\winreg.c
3a1eb0e
@AlexWaygood @erlend-aasland
Fix failing test
c5977a5
@erlend-aasland
Import ClinicError directly from libclinic
ac08f0f
@erlend-aasland erlend-aasland added the skip news label Feb 15, 2024
@erlend-aasland
erlend-aasland requested a review from a team as a code owner February 15, 2024 23:05
@erlend-aasland
erlend-aasland requested a review from AlexWaygood February 15, 2024 23:05
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 15, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Feb 15, 2024
Refactor Argument Clinic support code into libclinic #113299
Closed
@erlend-aasland
erlend-aasland removed the request for review from a team February 15, 2024 23:06
@zooba

zooba commented Feb 15, 2024

Copy link
Copy Markdown
Member

Can we not keep Tools/clinic/clinic.py so as not to break anyone who's scripted it/muscle memory?

Maybe also consider adding Tools/clinic/__main__.py so that python Tools/clinic works. May as well train people to type less, rather than more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland erlend-aasland removed the skip news label Feb 15, 2024
@erlend-aasland

erlend-aasland commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

Can we not keep Tools/clinic/clinic.py so as not to break anyone who's scripted it/muscle memory?

Let's consider it. @AlexWaygood: what do you think, as the author of the patch?

Maybe also consider adding Tools/clinic/__main__.py so that python Tools/clinic works. May as well train people to type less, rather than more.

Yes, that is a good idea.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Feb 15, 2024

Copy link
Copy Markdown
Member

Can we not keep Tools/clinic/clinic.py so as not to break anyone who's scripted it/muscle memory?

Let's consider it. @AlexWaygood: what do you think, as the author of the patch?

Yeah, I agree that makes more sense on the face of it. I think I tried it, but balked because it led to a much bigger diff, essentially destroying git blame. But maybe we should bite the bullet and do it anyway — UX probably trumps "DevX" here

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Feb 15, 2024

Copy link
Copy Markdown
Member

Also: thanks so much for picking this up!

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

Yeah, I agree that makes more sense on the face of it. I think I tried it, but balked because it led to a much bigger diff, essentially destroying git blame. But maybe we should bite the bullet and do it anyway — UX probably trumps "DevX" here

Ouch, yes that does mess up Git log pretty heavily! git log --follow Tools/clinic/clinic.py now yields the same history as git log --follow Tools/clinic/libclinic/clinic.py; that is unfortunate. I'm not sure Git history beats muscle memory in this case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland added 2 commits February 16, 2024 00:30
@erlend-aasland
Address review: add Tools/clinic/__main__.py
95a59d7
@erlend-aasland
Add NEWS
8b7dde7
@erlend-aasland

erlend-aasland commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

Turns out Git becomes extremely confused if we git mv Tools/clinic/run_clinic.py Tools/clinic/clinic.py. The cherry-picker will not work, since git log is confused. OTOH, as the current PR stands, cherry-picking works as expected. IMO, that is a very good argument for keeping run_clinic.py.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
PUll in main
7720c66
vstinner
vstinner reviewed Feb 16, 2024
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

What do you think of renaming libclinic to just clinic? And also move __main__.py in the sub-directory?

My intent is to be able to run python -m clinic ... when making the assumption that Tools/clinic/ is in the path.

Previously, "clinic" couldn't be used since Tools/clinic/ already contained clinic.py.

I hope that in the long term, we can provide clinic as part of the stdlib! And clinic sounds like a better name than libclinic.

By the way, while we move files all around, what do you think of renaming clinic to argclinic?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland

erlend-aasland commented Feb 16, 2024

Copy link
Copy Markdown
Contributor Author

What do you think of renaming libclinic to just clinic? And also move __main__.py in the sub-directory?

Something like this?

$ ls -lR Tools/clinic
total 24
drwxr-xr-x  10 erlend.aasland  staff  320 Feb 16 09:11 clinic
-rw-r--r--   1 erlend.aasland  staff  266 Jan 17 12:58 mypy.ini

Tools/clinic/clinic:
total 536
-rw-r--r--  1 erlend.aasland  staff    1413 Feb 16 09:07 __init__.py
-rw-r--r--  1 erlend.aasland  staff      70 Feb 16 09:11 __main__.py
-rw-r--r--  1 erlend.aasland  staff    6361 Feb 16 09:11 cli.py
-rw-r--r--  1 erlend.aasland  staff  229513 Feb 16 09:11 clinic.py
-rw-r--r--  1 erlend.aasland  staff    5918 Feb 15 23:59 cpp.py
-rw-r--r--  1 erlend.aasland  staff     638 Feb 15 23:59 errors.py
-rw-r--r--  1 erlend.aasland  staff    6671 Feb 16 09:07 formatting.py
-rw-r--r--  1 erlend.aasland  staff    1049 Feb 16 09:07 identifiers.py
-rw-r--r--  1 erlend.aasland  staff    1951 Feb 15 23:59 utils.py

My intent is to be able to run python -m clinic ... when making the assumption that Tools/clinic/ is in the path.

python -m clinic would have been nice, indeed.

I hope that in the long term, we can provide clinic as part of the stdlib! And clinic sounds like a better name than libclinic.

Currently, libclinic makes sense (we have clinic.py and a clinic lib with some refactored out code), but I agree it may be a temporary namespace. Here's a quick glance at what we do elsewhere in Tools/:

$ find Tools -name __main__.py
Tools/c-analyzer/c_parser/preprocessor/__main__.py
Tools/c-analyzer/c_parser/__main__.py
Tools/c-analyzer/cpython/__main__.py
Tools/c-analyzer/c_analyzer/__main__.py
Tools/peg_generator/pegen/__main__.py

Your suggestion aligns with existing practice.

By the way, while we move files all around, what do you think of renaming clinic to argclinic?

Let the painting begin 🎨🚲😄 My preference would be:

  1. clinic (no change)
  2. argument-clinic
  3. argument_clinic
  4. argclinic
Edgarruiz856 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Feb 16, 2024

Copy link
Copy Markdown
Contributor Author

@vstinner: but we are digressing; the linked issue is about refactoring Argument Clinic into smaller and more manageable pieces, and this PR is about separating out the command-line interface. If we want a new Argument Clinic namespace, or make Argument Clinic a part of the stdlib, we should have a broader discussion 😃 Let us not derail further from the PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Feb 16, 2024
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

LGTM if you remove __main__.py.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 16, 2024
@zooba

zooba commented Feb 19, 2024

Copy link
Copy Markdown
Member

You could use two commits/PRs to handle the Git history.

IIUC, Git doesn't track renames, it just calculates them when generating its history. That ought to happen for each commit, so if there's a commit that is clearly a move rather than a big edit, followed by another one that's clearly a move rather than a big edit, it ought to stay happy.

You can test with two commits on your own, but because we squash merge, it'll need to be separate PRs. The second one should just be a rename.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
Pull in main
c5bd50a
@erlend-aasland

erlend-aasland commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

@zooba, I see I did not clearly explain what I tested in #115542 (comment):

  1. squash this PR to main (simulate merge)
  2. git mv Tools/clinic/run_clinic.py Tools/clinic/clinic.py
  3. git log Tools/clinic/clinic.py is (still) confused
  4. create a dummy feature branch off of the test main branch; hack on Tools/clinic/libclinic/clinic.py
  5. cherry-pick the commit from 4. onto 3.12; this fails

If we don't rename run_clinic.py to clinic.py (that is, skip 2.), 5. works, because Git is able to follow the Tools/clinic/libclinic/clinic.py history back to Tools/clinic/clinic.py.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zooba

zooba commented Feb 20, 2024

Copy link
Copy Markdown
Member

Yeah, I guess Git is going to make this painful for everyone regardless of the choice.

Personally, calling it clinic-run.py rather than run_clinic.py would suit me (it's not meant to be imported so the hyphen is fine, and I usually tab complete the last bit). But whatever has to be done has to be done.

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Feb 20, 2024

Copy link
Copy Markdown
Member

clinic-run.py is fine by me!

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland

erlend-aasland commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

Yeah, I guess Git is going to make this painful for everyone regardless of the choice.

Well, there is the option just keeping the CLI in Tools/clinic/clinic.py, and putting everything else into libclinic.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland added 2 commits February 20, 2024 23:03
@erlend-aasland
Revert "Address review: add Tools/clinic/__main__.py"
730c3f9
This reverts commit 95a59d7.
@erlend-aasland
Pull in main
230e321
@erlend-aasland

erlend-aasland commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

LGTM if you remove __main__.py.

Removed with 730c3f9

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Feb 21, 2024

Copy link
Copy Markdown
Member

git mv Tools/clinic/run_clinic.py Tools/clinic/clinic.py

Please don't do that :-( If we have a clinic/ package (directory), put a __main__.py inside, and run it with python -m clinic in the right directory, or a script with any name except of clinic.py. If we have clinic.py and clinic/, it sounds very confusing :-(

Also, run_clinic.py can live in a different directory, like Tools/build/.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes Feb 21, 2024
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

LGTM, but be careful of outdated NEWS entry (and maybe the commit message? I didn't check.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Tools-Demos/2024-02-16-00-33-14.gh-issue-113299.lqPMAV.rst
@@ -0,0 +1,3 @@
The Argument Clinic CLI is now invoked as either :program:`python3
Tools/clinic` or :program:`python3 Tools/clinic/run_clinic.py`, as
:file:`Tools/clinic/clinic.py` has been refactored into ``libclinic``.

@vstinner vstinner Feb 21, 2024

Copy link
Copy Markdown
Member

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.

The NEWS entry is outdated, there is no __main__.py script.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@erlend-aasland erlend-aasland Feb 21, 2024

Copy link
Copy Markdown
Contributor Author

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.

Ohh, thanks; the NEWS entry was not part of the commit I reverted. Good catch.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@erlend-aasland

erlend-aasland commented Feb 21, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Personally, calling it clinic-run.py rather than run_clinic.py would suit me (it's not meant to be imported so the hyphen is fine, and I usually tab complete the last bit). But whatever has to be done has to be done.

@zooba: How about @vstinner's suggestion (a clinic package)? With Tools/clinic/clinic/__main__.py you could invoke Argument Clinic pretty much like you do today, just without the .py at the end.

$ python3 Tools/clinic/clinic
zooba reacted with thumbs up emoji Edgarruiz856 reacted with heart emoji
All reactions
  • 👍 1 reaction
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

erlend-aasland
erlend-aasland commented Feb 21, 2024
View reviewed changes
Comment thread Misc/NEWS.d/next/Tools-Demos/2024-02-16-00-33-14.gh-issue-113299.lqPMAV.rst
Comment on lines +1 to +3
The Argument Clinic CLI is now invoked as either :program:`python3
Tools/clinic` or :program:`python3 Tools/clinic/run_clinic.py`, as
:file:`Tools/clinic/clinic.py` has been refactored into ``libclinic``.

@erlend-aasland erlend-aasland Feb 21, 2024

Copy link
Copy Markdown
Contributor Author

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.

Suggested change
The Argument Clinic CLI is now invoked as either :program:`python3
Tools/clinic` or :program:`python3 Tools/clinic/run_clinic.py`, as
:file:`Tools/clinic/clinic.py` has been refactored into ``libclinic``.
The Argument Clinic CLI is now invoked as
:program:`python3 Tools/clinic/run_clinic.py`,
since :file:`Tools/clinic/clinic.py` has been refactored into ``libclinic``.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Feb 21, 2024

Copy link
Copy Markdown
Member

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.

Yep, I like this NEWS entry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zooba

zooba commented Feb 21, 2024

Copy link
Copy Markdown
Member

I'd rather make Tools/clinic executable than Tools/clinic/clinic, but that's because I'd rather have Tools on PYTHONPATH than Tools/clinic.

However, since I don't do either right now, and because clinic is the only one I ever run, I don't have a strong preference. Just don't commit us to something that is going to be difficult to change in the future or massively interferes with muscle-memory without being a usability/discoverability improvement.

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Feb 21, 2024

Copy link
Copy Markdown
Member

I'd rather make Tools/clinic executable than Tools/clinic/clinic

I would like to move clinic to the stdlib in the long term, so I would prefer to have Tools/clinic/clinic/__maini__.py. Since it sounds controversial, I proposed to not add __main__.py for now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland
erlend-aasland marked this pull request as draft February 27, 2024 22:56
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 27, 2024
@erlend-aasland

erlend-aasland commented Apr 3, 2024

Copy link
Copy Markdown
Contributor Author

Superseded by #117513.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@erlend-aasland erlend-aasland closed this Apr 3, 2024
@erlend-aasland
erlend-aasland deleted the extract-cli branch April 3, 2024 20:15
@vstinner vstinner mentioned this pull request Apr 3, 2024
gh-113317: Finish splitting Argument Clinic into sub-files #117513
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner will be requested when the pull request is marked ready for review AA-Turner is a code owner
@emmatyping emmatyping Awaiting requested review from emmatyping emmatyping will be requested when the pull request is marked ready for review emmatyping is a code owner
@itamaro itamaro Awaiting requested review from itamaro itamaro will be requested when the pull request is marked ready for review itamaro is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@erlend-aasland @zooba @AlexWaygood @vstinner
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.