从flake8测试中排除.env目录? [英] Exclude .env directory from flake8 tests?

查看:70
本文介绍了从flake8测试中排除.env目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从本地.env收到数千个flake8错误.一些错误消息的示例:

I'm getting thousands of flake8 errors stemming from my local .env. An example of some of the error messages:

./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3848:80: E501 line too long (85 > 79 characters)
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3848:84: E202 whitespace before ')'
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3855:51: E201 whitespace after '('
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3855:65: E202 whitespace before ')'
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3858:50: E201 whitespace after '('
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3858:78: E202 whitespace before ')'
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3861:31: E231 missing whitespace after ','
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3865:1: W293 blank line contains whitespace
./env/lib/python3.7/site-packages/pip/_vendor/pyparsing.py:3866:1: E302 expected 2 blank lines, found 1

我的目录如下:

我的flake8文件如下:

My flake8 file looks like this:

[flake8]
exclude =
    migrations,
    __pycache__,
    manage.py,
    settings.py,

问题

如何将我的环境文件内容添加到flake8的排除列表中?

Question

How can I add my env file contents to the exclude list in flake8?

我尝试添加:

  env,
./env,

我尝试过删除逗号并添加:

I've tried taking off commas and adding:

[flake8]
exclude =
    migrations
    __pycache__
    manage.py
    settings.py
    env
    .env
    ./env
    env/
    .env/

运行flake8-排除迁移, pycache ,manage.py,settings.py,env返回:

Running flake8 --exclude migrations,pycache,manage.py,settings.py,env returns:

./app/core/models.py:7:80: E501 line too long (93 > 79 characters)
./app/core/models.py:13:66: E225 missing whitespace around operator
./app/core/models.py:13:80: E501 line too long (103 > 79 characters)
./app/core/admin.py:10:1: W293 blank line contains whitespace
./app/core/admin.py:11:1: W293 blank line contains whitespace
./app/core/admin.py:13:1: W293 blank line contains whitespace
./app/core/tests/test_commands.py:23:47: W292 no newline at end of file
./app/core/management/commands/wait_for_db.py:21:69: W292 no newline at end of file
./app/project/urls.py:23:2: W292 no newline at end of file
./app/inventory/serializers.py:4:1: E302 expected 2 blank lines, found 1
./app/inventory/serializers.py:8:1: W391 blank line at end of file
./app/inventory/urls.py:5:70: W291 trailing whitespace
./app/inventory/urls.py:7:26: W292 no newline at end of file
./app/inventory/views.py:1:1: F401 'rest_framework.response.Response' imported but unused
./app/inventory/views.py:7:1: E302 expected 2 blank lines, found 1
./app/inventory/views.py:11:1: W293 blank line contains whitespace
./app/inventory/views.py:12:5: E303 too many blank lines (2)
./app/inventory/views.py:36:43: W292 no newline at end of file
./app/inventory/tests/test_api.py:2:1: F401 'django.urls.reverse' imported but unused
./app/inventory/tests/test_api.py:7:1: W293 blank line contains whitespace
./app/inventory/tests/test_api.py:9:8: E111 indentation is not a multiple of four
./app/inventory/tests/test_api.py:10:8: E111 indentation is not a multiple of four
./app/inventory/tests/test_api.py:10:40: W291 trailing whitespace
./app/inventory/tests/test_api.py:11:1: W293 blank line contains whitespace
./app/inventory/tests/test_api.py:12:8: E111 indentation is not a multiple of four
./app/inventory/tests/test_api.py:13:8: E111 indentation is not a multiple of four
./app/inventory/tests/test_api.py:18:41: W291 trailing whitespace
./app/inventory/tests/test_api.py:19:1: W293 blank line contains whitespace
./app/inventory/tests/test_api.py:25:37: W291 trailing whitespace
./app/inventory/tests/test_api.py:26:41: W291 trailing whitespace
./app/inventory/tests/test_api.py:27:1: W293 blank line contains whitespace
./app/inventory/tests/test_api.py:31:1: W391 blank line at end of file
./app/inventory/tests/test_api.py:31:1: W293 blank line contains whitespace

推荐答案

我注意到您的 .flake8 文件位于 app 文件夹中.我想您是从 app 文件夹外部(即从项目根目录)开始 flake8 .

I notice your .flake8 file is inside app folder. I presume you are starting flake8 from outside the app folder, in other words from the project root.

.flake8 移至项目根目录,一切都会正常进行:

Move .flake8 to the project root, and everything's gonna work:

mv app/.flake8 .

这篇关于从flake8测试中排除.env目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆