Skip to content
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

Pyreverse: PlantUML support + coloring (from PR #4521) #4615

Closed
wants to merge 35 commits into from

Conversation

DudeNr33
Copy link
Collaborator

Steps

  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

This is a rather large PR, so I try my best to summarize the changes.
It solves both #4488 and #4498.
The requested changes from PR #4521 are already included, and PR #4521 can be deleted (the introduction of NamedTuple for better typing was easier to do with the changes already made for the PlantUML support).

So here is an overview what this PR includes:

  1. New Features:

    • Optional parameters --colorized and --max-color-depth to automatically color classes/modules of the same package (merged from PR Pyreverse autocolor #4521)
    • Implement a PlantUmlPrinter to support output to .puml files.
      Note that automatic conversion to .png or other image formats is not supported yet; specifying "png" as output format will still rely on the Dot backend.
    • Positive side effect of refactoring: The various import-graphs provided by the ImportsChecker can now be produced in .vcg and .puml format, not only .dot.
  2. Refactoring:

    • Defined a common Printer interface in pylint.pyreverse.printer for the possible backends (Dot, VCG, PlantUML).
      Moved DotBackend and VCGPrinter to printer module.
    • YAGNI: remove optional parameters from various methods in the Printer subclasses that were never used by the callers in the codebase, to find a minimal superset of parameters for each method signature.
    • Introduce factory function for picking the corresponding Printer or DiagramWriter subclass for the desired output format.
    • Remove module pylint.graph as it is no longer needed (DotBackend is replaced by pylint.pyreverse.printer.DotPrinter). Same for pylint.pyreverse.vcgutils.
      Move orphaned get_cycles() function to pylint.checkers.imports, which is (in my opinion) the better place for it anyway.
    • Refactor tests:
      • move to own subdirectory
      • split into functional tests and unit tests
      • extract for pyreverse.utils into own test module
    • Improve typing by adding type hints and use NamedTuples etc. where appropriate.
    • Use a consistent style for defining the dictionaries of the configuration options
    • Improve exclude rules in the pre-commit-config.yaml so it does not need to be expanded every time a new data subdirectory or a new conftest.py is added to the tests.

Type of Changes

Type
✨ New feature
🔨 Refactoring

Related Issue

Closes #4488
Closes #4498

…hod ``get_package_properties``.

Rename ``get_values`` to ``get_class_properties``.
VCGWriter and VCGPrinter thus no longer need special handling.
Refactor coloring logic into own Mixin class that can be used for both ``DotWriter`` and ``PlantUmlWriter``
…ately 'wrong' code.

Check top level ``conftest.py`` but ignore remaining ones, as this raises mypy errors for duplicate modules.
…nts and introduce proper subclasses for different kinds of diagram entities.
…ass suitable for the given output format
…is also not necessary anymore.

The "shape" is now automatically set by the ``Printer`` classes.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 92.447% when pulling 49ba34e on DudeNr33:pyreverse-plantuml into 1e55ae6 on PyCQA:master.

@DudeNr33 DudeNr33 marked this pull request as ready for review June 27, 2021 12:53
@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component pyreverse Related to pyreverse component labels Jun 27, 2021
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Hey, sorry for the delay before reviewing. There's a lot to review here and I never got a long enough period to do it properly. Could you rebase on the latest main, fix the conflicts, and put the changelog in 2.10 instead of 2.9 first, please ? If there are little changes that could be reviewed as a standalone MR, we could merge them first and that would help with the review time.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.10.0 milestone Jul 12, 2021
@DudeNr33
Copy link
Collaborator Author

Splitting this MR into smaller parts would certainly be possible.
That would probably be:

  1. Refactoring towards the common Printer base class, as prerequisite for the following changes
  2. Introduction of type annotations
  3. Refactoring of tests
  4. Introduction of PlantUMLPrinter and PlantUMLWriter
  5. Introduction of the ColorMixin class

1 & 2 might fit together well into one MR.
In this case I would not rebase this MR, as it would no longer be needed. I don't know if merging the "preparation" MRs into this one would go cleanly.

@Pierre-Sassoulas
Copy link
Member

Sound great, I don't mind if we open a dozen of new MR and close this one :)

@Pierre-Sassoulas
Copy link
Member

Closing in favor of #4850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component pyreverse Related to pyreverse component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permit to generate plantuml diagram with pyreverse Proposal: automatically color modules in package diagram
3 participants