Skip to content

version_option module name and package name are not equivalent #2331

@ice-tong

Description

@ice-tong

Environment:

  • Python version: 3.8
  • Click version: 8.1

The click.version_option uses the module name to get the package version :

if f_globals is not None:
package_name = f_globals.get("__name__")
if package_name == "__main__":
package_name = f_globals.get("__package__")
if package_name:
package_name = package_name.partition(".")[0]

But module name and package name are not always equivalent. This could be crash when the module name not the same as the package name, eg. open-mmlab/mim#152

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugf:parametersfeature: input parameter types

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions