最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to add a format script in a Poetry project that runs the Black formatter over a specific directory? - Stack Overflo

programmeradmin1浏览0评论

I would like to add a script to my Poetry project that runs the Black formatter over a specific directory. I wrote this:

[tool.poetry.scripts]
    format-scripts = "black:main scripts/**/*.py"

But it doesn't work. I am getting this error when running poetry run format-scripts:

Warning: 'format-scripts' is an entry point defined in pyproject.toml, but it's not installed as a script. You may get improper `sys.argv[0]`.

The support to run uninstalled scripts will be removed in a future release.

Run `poetry install` to resolve and get rid of this message.

  File "<string>", line 1
    import sys; from importlib import import_module; sys.argv = ['format-scripts']; sys.exit(import_module('black').main scripts/**/*.py())
                                                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you fot a comma?

I tried removing the scripts/**/*.py path from the script, like so:

[tool.poetry.scripts]
    format-scripts = "black:main"

This made it work, but I'm still getting the warning:

poetry run format-scripts scripts/**/*.py
Warning: 'format-scripts' is an entry point defined in pyproject.toml, but it's not installed as a script. You may get improper `sys.argv[0]`.

The support to run uninstalled scripts will be removed in a future release.

Run `poetry install` to resolve and get rid of this message.

All done! ✨ 

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论