- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 flakehell 作为预提交 Hook 运行。
我的 .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: flakehell
name: flakehell
entry: flakehell lint project/
language: python
pass_filenames: true
stages: [push, commit]
verbose: true
pyproject.toml:
[tool.flakehell]
exclude = ["README.md"]
format = "colored"
show_source = true
[tool.flakehell.plugins]
flake8-bandit = ["+*", "-S322"]
flake8-bugbear = ["+*"]
flake8-builtins = ["+*"]
flake8-comprehensions = ["+*"]
flake8-darglint = ["+*"]
flake8-docstrings = ["+*"]
flake8-eradicate = ["+*"]
flake8-isort = ["+*"]
flake8-mutable = ["+*"]
flake8-pytest-style = ["+*"]
flake8-spellcheck = ["+*"]
mccabe = ["+*"]
pep8-naming = ["+*"]
pycodestyle = ["+*"]
pyflakes = ["+*"]
pylint = ["+*"]
还有一些问题。当我尝试使用 git commit 时,我看到 flakehell 开始工作。几秒钟后它失败了,我得到了错误:
“UnicodeDecodeError: 'utf-8' 编解码器无法解码位置 10 中的字节 0xb8: 无效起始字节”
没有“预提交”它会很好用(我的意思是当我只输入“flakehell lint”时)
是否可以将 flakehell 配置为预提交?
如果没有 - 您是否为 python 项目推荐任何更好/有效的解决方案?
最佳答案
您的配置不正确,您没有使用 files
或 types
限制传递给您的钩子(Hook)的文件,因此它默认为您存储库中的所有文件.大概你有一些二进制文件正在传递给 flakehell
我还注意到您的配置同时传递了一个路径并具有 pass_filenames: true
(pass_filenames: true
是默认设置,因此您不应该使用它)
您要么想要在 args 中列出路径(不推荐,因为您总是 lint 超过您正在更改的内容)或者您想要正确过滤文件名
此外,verbose: true
不适合在调试之外使用,因为它会给输出添加警告噪音
此外,您不是通过预提交管理 flakehell 的安装,这会给您的贡献者增加额外的负担,以尝试在本地设置任何开发环境,预提交的大部分 Gist 是它管理安装您的工具,这样您的贡献者就不必费力地进行正确的格式化/linting 设置(消除一整类“它在我的机器上工作”的问题)
此外,flakehell 似乎直接支持预提交,所以你不需要像你正在做的那样使用 repo: local
逃生舱口
把所有这些放在一起,你可能想要这样的东西:
repos:
- repo: https://github.com/life4/flakehell
rev: v.0.7.1
hooks:
- id: flakehell
如果您想使用本地配置,您可能需要以下内容:
repos:
- repo: local
hooks:
- id: flakehell
name: flakehell
entry: flakehell lint
types: [python]
files: ^project/
language: python
additional_dependencies: [flakehell==0.7.1]
stages: [push, commit]
免责声明:我是 pre-commit 的创建者
关于python - 带有 .toml 配置和预提交钩子(Hook)的 Flakehell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65658117/
我有一个 TOML 文档,其中某些键可能存在也可能不存在。例如。该文件是有效文件: foo = "bar" 但这也是有效的: foo = "bar" something = "else" 我现在正尝试
我正在使用 Dynaconf (3.1.2) 来处理我的 python 应用程序设置。 如果我在 settings.toml 和 .secrets.toml 中使用相同的 key ,则这些部分最后仅包
我正在使用 Dynaconf (3.1.2) 来处理我的 python 应用程序设置。 如果我在 settings.toml 和 .secrets.toml 中使用相同的 key ,则这些部分最后仅包
TOML said“TOML和YAML都强调人类的可读性,例如使人们更容易理解给定行目的的注释。TOML的不同之处在于将它们组合在一起,允许注释(与JSON不同),但保留了简单性(与YAML不同)。”
我正在尝试为 TOML 文档实现可链接的查询执行。 A Query是更改 TOML 文档并可能返回另一个 Query 的东西应在其自身之后执行的对象。 Query执行的获取前一个查询的结果(如果有的话
看着 toml repo ,我没有看到任何关于键命名约定的限制/建议 看起来大部分变量都是 lowercase但想知道 key 的最佳实践 - 命名约定是什么? 假设我想要一个名为 firstname
我想从 TOML 文件生成 JSON。 JSON 结构应该是这样的,在对象数组中包含对象数组: { "things": [ { "a": "thing1
背景 我正要尝试从GitHub下载的Python包,发现它没有setup.py ,所以我无法安装它 pip install -e 相反,该软件包具有 pyproject.toml 文件似乎具有与 s
获取以下 TOML 数据: [[items]] foo = 10 bar = 100 [[items]] foo = 12 bar = 144 还有下面的 rust 代码: use serde_der
“WSO IS 5.9.0”的新功能是 deployment.toml ,但我还没有找到配置选项,也没有找到如何从这个文件设置 xml 配置文件的方法。 例如,如果我想在 carbon.xml 中启用
“WSO IS 5.9.0”的新功能是 deployment.toml ,但我还没有找到配置选项,也没有找到如何从这个文件设置 xml 配置文件的方法。 例如,如果我想在 carbon.xml 中启用
从 toml 文件中读取的字符串值包含额外的引号: # Toml file string_key = "fdsafdsafdsfds" 代码: let cfg_file_content = g
我正在尝试读取 TOML 文件以创建一个结构,该结构包含具有关联值的枚举向量。这是示例代码: extern crate serde; #[macro_use] extern crate serde_d
我有共享公共(public)资源且无法同时执行的测试。这些测试因 cargo test 而失败,但适用于 RUST_TEST_THREADS=1 cargo test。 我可以修改测试以等待全局互斥锁
我使用以下方式安装了依赖项: go get github.com/BurntSushi/toml 我在与 main.go 相同的文件夹中创建了一个 toml 文件: . |-- cloud.toml
我有一个包含两个可执行文件的 Rust 项目: src └── bin ├── app.rs └── tool.rs tool 程序作为app 的子进程运行。 (需要进行分离,因为 t
背景 我目前正在编写一个绑定(bind) C 库的 crate ,我需要用户指定构建库的位置。以前,我见过 llvm-sys 的句柄crate 使用环境变量。但是,如果我经常使用它,每次我想运行一个项
所以我在 GitHub 存储库中有几个文件,我想设置一个自定义的 404 错误页面。当我搜索它时,它要求我在 netlify.toml 中插入一些东西。文件,它应该在我的根目录中(我认为这意味着存储库
Pip 支持 pyproject.toml文件,但到目前为止,新模式的所有实际使用都需要一个 3rd 方工具来自动生成这些文件(例如,诗歌和 pip)。不像 setup.py这已经是人类可写的,pyp
我希望有这样的东西:cargo install stopwatch 但在文档中找不到它。 查找包版本并手动将包添加到.toml: [dependencies] stopwatch="0.0.6" 感觉
我是一名优秀的程序员,十分优秀!