[BE] Add flake8-logging-format linter (#94840)

Follow up to #94708
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94840
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2023-02-15 17:54:50 +00:00
committed by PyTorch MergeBot
parent dc4f2af6f6
commit b46b2e35d4
5 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,6 @@
[flake8]
select = B,C,E,F,P,T4,W,B9
enable-extensions = G
select = B,C,E,F,G,P,T4,W,B9
max-line-length = 120
# C408 ignored because we like the dict keyword argument syntax
# E501 is not flexible enough, we're using B950 instead
@ -12,6 +13,8 @@ ignore =
B007,B008,
# these ignores are from flake8-comprehensions; please fix!
C407
# these ignores are from flake8-logging-format; please fix!
G001,G002,G003,G004,G100,G101,G200,G201,G202
per-file-ignores =
__init__.py: F401
torch/utils/cpp_extension.py: B950

View File

@ -35,6 +35,7 @@ init_command = [
'flake8-bugbear==20.1.4',
'flake8-comprehensions==3.3.0',
'flake8-executable==2.0.4',
'flake8-logging-format==0.9.0',
'flake8-pyi==20.5.0',
'mccabe==0.6.1',
'pycodestyle==2.6.0',

View File

@ -2,6 +2,7 @@ flake8==3.8.2
flake8-bugbear==20.1.4
flake8-comprehensions==3.3.0
flake8-executable==2.0.4
flake8-logging-format==0.9.0
git+https://github.com/malfet/flake8-coding.git
flake8-pyi==20.5.0
mccabe==0.6.1

View File

@ -491,7 +491,7 @@ class _NnapiSerializer:
raise Exception("Flexible size is not supported for this operand.")
if s < 0:
# runtime flex
LOG.warn(f"Operand {oper} has runtime flex shape")
LOG.warning(f"Operand {oper} has runtime flex shape")
return op_id, oper
def get_tensor_operand_or_constant(self, jitval, dim_order=DimOrder.PRESUMED_CONTIGUOUS):

View File

@ -61,7 +61,7 @@ def _calc___package__(globals):
spec = globals.get("__spec__")
if package is not None:
if spec is not None and package != spec.parent:
_warnings.warn(
_warnings.warn( # noqa: G010
"__package__ != __spec__.parent " f"({package!r} != {spec.parent!r})",
ImportWarning,
stacklevel=3,
@ -70,7 +70,7 @@ def _calc___package__(globals):
elif spec is not None:
return spec.parent
else:
_warnings.warn(
_warnings.warn( # noqa: G010
"can't resolve package from __spec__ or __package__, "
"falling back on __name__ and __path__",
ImportWarning,