flake8 e999 关于在 python2 中使用 fstrings(使用 future_fstrings)
flake8 e999 on using fstrings in python2 (with future_fstrings)
我在 pip install future-fstrings
之后在 python2 中使用 fstrings,如下所示:
# -*- coding: future_fstrings -*-
class A(object):
def __init__(self, **kw):
self.__dict__.update(**kw)
print (f'{self.a}')
print (f'{self.b}')
print (f'{self.c}')
A(a=1,b=2,c=3)
但是,当将这样的文件提交到我的项目时,我得到:
flake8 (Python 3.6 syntax check).....................(no files to check)Skipped
flake8 (Python 2.7)......................................................Failed
hookid: flake8
file_name:0:1: E999 SyntaxError: unknown encoding: future_fstrings
为什么会发生这种情况,我该如何解决?
# noqa E999
没用...
预提交为每个挂钩创建隔离环境
您需要为该 linter 提供 future-fstrings:
- id: flake8
additional_dependencies: [future-fstrings]
完全披露:我是 pre-commit 和 future-fstrings 的作者,也是 flake8 的维护者,当它们都重叠时很疯狂嘿
我在 pip install future-fstrings
之后在 python2 中使用 fstrings,如下所示:
# -*- coding: future_fstrings -*-
class A(object):
def __init__(self, **kw):
self.__dict__.update(**kw)
print (f'{self.a}')
print (f'{self.b}')
print (f'{self.c}')
A(a=1,b=2,c=3)
但是,当将这样的文件提交到我的项目时,我得到:
flake8 (Python 3.6 syntax check).....................(no files to check)Skipped
flake8 (Python 2.7)......................................................Failed
hookid: flake8
file_name:0:1: E999 SyntaxError: unknown encoding: future_fstrings
为什么会发生这种情况,我该如何解决?
# noqa E999
没用...
预提交为每个挂钩创建隔离环境
您需要为该 linter 提供 future-fstrings:
- id: flake8
additional_dependencies: [future-fstrings]
完全披露:我是 pre-commit 和 future-fstrings 的作者,也是 flake8 的维护者,当它们都重叠时很疯狂嘿