Skip to content

Run a module without any functions #322

@alecmev

Description

@alecmev
  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

I'm writing a simple one-off script, without any functions, and I'd like to run it through Poetry, in its virtual environment. However, it appears this currently isn't possible, as Poetry expects a callable:

https://github.com/sdispater/poetry/blob/af8f86cda703144e9261b700d3165433aa2d3603/poetry/console/commands/run.py#L35-L37

My Python is rusty, so maybe there's a way around this (which makes it a documentation concern), but if there isn't, I suggest adding a quick heuristic, checking for the presence of a colon, and just executing import_module('{}') instead of import_module('{}').{}() otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions