Skip to content

Refactor Argument Clinic support code into libclinic #113299

Description

@vstinner

Argument Clinic was added 10 years ago. The script clinic.py grown from around 2500 lines to around 6700 lines.

I propose to split this large file into sub-files to ease the maintenance of Argument Clinic.

Linked PRs

Activity

  1. added a commit that references this issue on Dec 20, 2023
  2. erlend-aasland commented on Dec 20, 2023

    @erlend-aasland
    Contributor

    This has also been discussed before. See #104683 (comment).

  3. erlend-aasland commented on Dec 20, 2023

    @erlend-aasland
    Contributor

    I think it is a really good idea to split clinic.py into multiple files. The C preprocessor stuff is already separated out (cpp.py). We should do this in iterations; not everything in one big PR. Perhaps it is easiest to start with the converters; it's a large chunk of clinic.py, and I think it would be pretty easy to separate it from the rest. Separating out the application is also a good start.

    Moreover, doing this work in chunks/iterations, instead of everything in one go, will minimise the impact on ongoing Argument Clinic work.

  4. AlexWaygood commented on Dec 20, 2023

    @AlexWaygood
    Member

    +1 to splitting clinic.py up, and +1 to doing it incrementally rather than in one big PR.

    Previously I've held off from doing something like this because clinic.py's use of global variables means that lots of parts of the file are tightly coupled to other parts in surprising and unfortunate ways. In #113300, warn() and fail() still use a global clinic variable in utils.py, but that variable is now altered from code in other files, making it even harder to understand what's going on. That feels worse, and it feels like we're avoiding solving the actual problem here, which is that clinic.py just shouldn't really be using global variables like this in the first place.

    But maybe it's acceptable for now, if splitting the code up into several files is a higher priority :) Getting rid of the global variables is hard!

  5. erlend-aasland commented on Dec 20, 2023

    @erlend-aasland
    Contributor

    IMO, getting rid of the global variables should be a prerequisite to splitting things up. We don't need to rush this; clinic.py has been a single file since it started out in life. Argument Clinic is already hard to comprehend, so any refactoring, including splitting up should make it more readable, not the other way around. Readability is IMO the highest priority.

  6. added a commit that references this issue on Dec 20, 2023
  7. vstinner commented on Dec 20, 2023

    @vstinner
    Author
  8. AlexWaygood commented on Dec 20, 2023

    @AlexWaygood
  9. erlend-aasland commented on Dec 20, 2023

    @erlend-aasland
  10. erlend-aasland commented on Dec 20, 2023

    @erlend-aasland
  11. vstinner commented on Dec 20, 2023

    @vstinner
    Author
  12. changed the title [-]Argument Clinic: split clinic.py into sub-files[/-] [+]Refactor Argument Clinic support code into libclinic[/+] on Dec 27, 2023
  13. erlend-aasland commented on Dec 27, 2023

    @erlend-aasland
    Contributor

    Since last week, we've done a lot of yak-shaving (and there is more to be done). A bare bones libclinic has been established, containing most of the stateless formatting code. The next steps will be to move ClinicError into libclinic/errors.py, and rename cpp.py to libclinic/cpp.py.

  14. erlend-aasland commented on Dec 27, 2023

    @erlend-aasland
    Contributor

    libclinic/errors.py was established via #113525.

  15. added a commit that references this issue on Dec 27, 2023
  16. added a commit that references this issue on Dec 27, 2023
  17. added a commit that references this issue on Jan 22, 2024
  18. added a commit that references this issue on Feb 11, 2024
  19. erlend-aasland commented on Apr 3, 2024

    @erlend-aasland
    Contributor

    Superseded by #113317

  20. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions