Bla*_*bon 5 python tdd docker testdriven.io
按照“FastAPI-TDD with Docker”课程,我让项目在本地构建和传递,然后在 github 操作中失败:
似乎源中的进攻线是:
response = test_app_with_db.get(f"/summaries/")
Run Code Online (Sandbox Code Playgroud)
Github Action 结果是:
Run docker exec fastapi-tdd python -m flake8 .
docker exec fastapi-tdd python -m flake8 .
shell: /bin/bash -e {0}
env:
IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/web
./app/db.py:14:1: E303 too many blank lines (3)
./tests/test_ping.py:4:1: F401 'app.main' imported but unused
./tests/test_summaries.py:6:1: F401 'pytest' imported but unused
./tests/test_summaries.py:60:37: F541 f-string is missing placeholders
##[error]Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
Enr*_*ado 13
我在使用 flake8 检查代码时遇到错误。问题很简单,我使用 f 字符串来处理可能只是字符串的东西。
\n当您插入变量时,f 字符串有意义,例如:
\nf字符串的正确使用
\nage = 34\nprint(f'Hi my name is Enrique and my age is {age} years old')\nRun Code Online (Sandbox Code Playgroud)\n但如果你只是输入一个没有变量的字符串,那么你就错误地使用了 f-string
\nf 字符串的错误使用
\nprint(f'Hi my name is Enrique and my age is 34 years old')\nRun Code Online (Sandbox Code Playgroud)\n在这种情况下,您不需要使用 f 字符串,因为您没有在字符串中插入任何变量
\n小智 6
f 字符串与占位符一起使用 示例:如果您想将 '/summary/' 放在 f 字符串中,请将其分配给某个变量,然后将该变量放在占位符中
语法是
f'{variable}'
Run Code Online (Sandbox Code Playgroud)
例子 :
f'{"quoted string"}'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13008 次 |
| 最近记录: |