Skip to content

v2.8.1

Latest

Choose a tag to compare

@Technologicat Technologicat released this 22 Aug 09:42
· 6 commits to master since this release

Hotfix release.

Fixed

  • --module-level no longer drops every dependency on a package itself. A package's __init__.py was registered under the name pkg.__init__, while import pkg records a dependency on pkg — so the edge pointed at a module that, as far as the graph was concerned, did not exist, and was discarded without a warning. Both directions went: a module importing a name re-exported from pkg/__init__.py showed no dependency at all, and the package's own imports vanished with the node they started from.

    • The __init__ is now drawn as the package, under the name pkg. --init still draws it separately as pkg.__init__, together with the implicit dependency every module under the package has on it — which is what the default omits, and what it was trying to omit all along.
    • An __init__.py naming its own package — from harbor import quay, written in harbor/__init__.py — resolves to the module the import is written in, and draws nothing. A module does not depend on itself.
    • Still missed: from . import thing, where thing is a name defined in __init__.py rather than a submodule. Recorded in TODO_DEFERRED.md, along with the cycle report naming a package pkg.__init__ where the graph now says pkg.
  • Ungrouped output now names a module by its dotted path. --module-level labelled modules with their short name, so in a project with several packages holding a utils or an app, distinct modules printed identically and --text ran their entries together as though they were one. Grouped output was unaffected, the cluster title supplying the package; so was the call graph, which builds module nodes with the whole path in the name. That is now the form both use.

  • A misspelled option is now an error instead of being ignored. Filenames are whatever the argument parser does not claim, so --with-init — a plausible misspelling of --init — was taken for a glob, matched nothing, and left pyan running with the setting the user was trying to change. Both the call graph and --module-level were affected. A glob matching no files is likewise an error in --module-level now, as it already was for the call graph.

  • What the graph leaves out now describes grouped output correctly, and gives an example of each rule. Every module is drawn as a box under --grouped; the README said a module without members stays a plain node, which it does not — an empty __init__.py gets a box holding <module> alone. Only the first of the culling rules came with an example, so the rest have one now.

    • It also warns that folding a lambda or comprehension into its enclosing function hides a scope boundary Python really has, so a call made inside one cannot be told from a call in the function body. Name resolution is unaffected — a lambda parameter or comprehension target shadows the enclosing binding, as it should.