下一个Python项目的终极设置

其它相关内容
问题讨论
回复
头像
shaoziyang
帖子: 3917
注册时间: 2019年 10月 21日 13:48

下一个Python项目的终极设置

#1

帖子 shaoziyang »

来自:https://martinheinz.dev/blog/14

无论您是从事某些机器学习/人工智能方面的工作,还是在Flask中构建Web应用程序,或者只是编写一些快速的Python脚本,为您的项目准备一些满足您所有需求的模板总是很有用的,即:预定义的目录结构、所有必需的配置pytest.ini或的文件,例如requirements.txt,测试/整理和静态代码分析设置,CI / CD工具,应用程序的Docker化以及使用Makefile实现自动化的基础。因此,在这里,我将为您的Python项目带来一个“终极”的通用设置

目录结构

代码: 全选

├── blueprint # Our source code - name of the application/module
│ ├── app.py
│ ├── __init__.py
│ ├── __main__.py
│ └── resources
├── tests
│ ├── conftest.py
│ ├── context.py
│ ├── __init__.py
│ └── test_app.py
├── .github # GitHub Actions
│ └── workflows
│ ├── build-test.yml
│ └── push.yml
├── Makefile
├── configure_project.sh
├── setup.cfg
├── pytest.ini
├── requirements.txt
├── dev.Dockerfile
└── prod.Dockerfile
 配置文件

代码: 全选

[flake8]
exclude =
    .git,
    __pycache__,
    .pytest_cache,
    venv

ignore =
    # Put Error/Style codes here e.g. H301

max-line-length = 120
max-complexity = 10

[bandit]
targets: blueprint

[coverage:run]
branch = True
omit =
    */__main__.py
    */tests/*
    */venv/*

[coverage:report]
exclude_lines =
    pragma: no cover
    if __name__ == .__main__.:

[coverage:html]
directory = reports

[pylint]
...  # 100 lines of config...
更多内容请参考上面原文链接。
 

回复

  • 随机主题
    回复总数
    阅读次数
    最新文章