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

I would like to add a script to my Poetry project that runs the Black formatter over a specific directo

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! ✨ 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745298301a4621278.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信