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

allow publishing a more detailed graph #15195

Open
purajit opened this issue Dec 30, 2024 · 2 comments
Open

allow publishing a more detailed graph #15195

purajit opened this issue Dec 30, 2024 · 2 comments
Labels
analyze Related to Ruff analyze functionality needs-decision Awaiting a decision from a maintainer

Comments

@purajit
Copy link
Contributor

purajit commented Dec 30, 2024

In addition to the options to publish the graph based on module paths and including third-party deps
mentioned in #13431, publishing a --detailed graph would be great! It would allow people to build or
conceive of several other tools on top of ruff, and also allow ruff to swallow them up.

This could include information like:

  • whether this is from a string or not
    • if it could go so deep as to being able to detect whether it's being mocked, dynamically imported,
      opened as a pkg resource, etc, that would be absolutely nuts, at least in obvious cases
  • whether this is TYPING-only
  • whether this is a top-level import or not
  • whether private members are imported (I guess this starts pushing the graph towards being not
    just for modules but for module members)
  • whether it's a relative import
  • any attached annotations (particularly pylint, also semgrep)

I understand there would be some non-trivial restructure or reconsideration, since there could be multiple
dependencies on the same module with differing characteristics

@MichaReiser MichaReiser added needs-decision Awaiting a decision from a maintainer analyze Related to Ruff analyze functionality labels Dec 30, 2024
@nickdrozd
Copy link
Contributor

This is a great idea. Other info that would be nice to have:

  • Stats about module imports
    • For a given module, how many modules import it?
    • Total number of imports
    • Modules that import the most / are imported the most
  • Transitive imports, i.e. A imports from B, B imports from C, but also A imports from C (could indicate interface design flaw)
  • Could enforce a maximum number of module imports, since too many imports could indicate design flaw.

@purajit
Copy link
Contributor Author

purajit commented Jan 6, 2025

@nickdrozd aren't the first 2 derivable from the graph it already outputs? For example, my
project https://github.com/purajit/ruff-tools is all about transitive deps, as well as detecting
cyclical deps, etc. I feel any derivable information should be left up to individual users.

For the last one, that sounds like a new ruff linter rule so would be better as a separate proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyze Related to Ruff analyze functionality needs-decision Awaiting a decision from a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants