Files
huangjingwei 51dfba6e6f Static checking tools and rules are adopted directly from pytorch.
Co-authored-by: JingweiHuang<huangjingwei4@huawei.com>



# message auto-generated for no-merge-commit merge:
!32658 merge code-check into master

Static checking tools and rules are adopted directly from pytorch.

Created-by: huangjingwei
Commit-by: JingweiHuang
Merged-by: ascend-robot
Description: <!--
PR描述模板更新日期:20260203
-->

# 【合入来源】
> <font color="red">**如有社区issue,请关联issue链接**</font>\
> <font color="red">**请勿携带内部流程信息(需求链接、问题单、内部issue等)**</font>

- [ ] 需求
- [ ] 问题单
- [ ] issue/工单
- [x] 重构优化
- [ ] 资料更新

# 【修改方案】
> 请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用1、2、3、...进行罗列\
> 如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

# 【资料变更】
> 请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

# 【接口变更】
> 请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

# 【功能验证】
> 说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤\
> 新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

本地(工作区+HEAD提交)静态检查执行结果:

![image.png](https://raw.gitcode.com/user-images/assets/7404318/3f2cbc59-8c07-4d37-8545-14cd49b195be/image.png 'image.png')

# 【CheckList】
> PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

- [ ] 代码注释完备,正确记录错误日志
- [ ] 代码实现进行了返回值、空指针等校验
- [ ] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [ ] PR持续集成流水线(CI)执行通过,代码检查无异常


See merge request: Ascend/pytorch!32658
2026-04-23 11:37:29 +08:00

312 lines
6.1 KiB
INI

# This is the PyTorch mypy.ini file (note: don't change this line! -
# test_run_mypy in test/test_type_hints.py uses this string)
[mypy]
plugins = mypy_plugins/check_mypy_version.py, mypy_plugins/sympy_mypy_plugin.py
cache_dir = .mypy_cache/normal
allow_redefinition = True
warn_unused_configs = True
warn_redundant_casts = True
show_error_codes = True
show_column_numbers = True
check_untyped_defs = True
disallow_untyped_defs = True
disallow_untyped_decorators = True
follow_imports = normal
local_partial_types = True
enable_error_code = possibly-undefined
# do not re-enable this:
# https://github.com/pytorch/pytorch/pull/60006#issuecomment-866130657
warn_unused_ignores = False
#
# Note: test/ still has syntax errors so can't be added
#
# Typing tests is low priority, but enabling type checking on the
# untyped test functions (using `--check-untyped-defs`) is still
# high-value because it helps test the typing.
#
files =
torch,
caffe2,
test/test_bundled_images.py,
test/test_bundled_inputs.py,
test/test_complex.py,
test/test_datapipe.py,
test/test_futures.py,
test/test_numpy_interop.py,
test/test_torch.py,
test/test_type_hints.py,
test/test_type_info.py,
test/test_utils.py
#
# `exclude` is a regex, not a list of paths like `files` (sigh)
#
exclude = torch/include/|torch/csrc/|torch/distributed/elastic/agent/server/api.py|torch/testing/_internal|torch/distributed/fsdp/fully_sharded_data_parallel.py
python_version = 3.11
#
# Extension modules without stubs.
#
[mypy-torch.for_onnx.onnx]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.apot_utils]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.quantizer]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.observer]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.APoT_tensor]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.fake_quantize_function]
ignore_missing_imports = True
[mypy-torch.ao.quantization.experimental.fake_quantize]
ignore_missing_imports = True
[mypy-torch.ao.quantization.pt2e._affine_quantization]
ignore_errors = True
#
# Files with various errors. Mostly real errors, possibly some false
# positives as well.
#
[mypy-test_torch]
check_untyped_defs = False
# Excluded from mypy due to OpInfos being annoying to type
[mypy-torch.testing._internal.common_methods_invocations.*]
ignore_errors = True
[mypy-torch.testing._internal.hypothesis_utils.*]
ignore_errors = True
[mypy-torch.testing._internal.common_quantization.*]
ignore_errors = True
[mypy-torch.testing._internal.generated.*]
ignore_errors = True
[mypy-torch.testing._internal.distributed.*]
ignore_errors = True
[mypy-torch.nn.modules.pooling]
ignore_errors = True
[mypy-torch.nn.parallel._functions]
ignore_errors = True
[mypy-torch._appdirs]
ignore_errors = True
[mypy-torch.multiprocessing.pool]
ignore_errors = True
[mypy-torch.overrides]
ignore_errors = True
#
# Files with 'type: ignore' comments that are needed if checked with mypy-strict.ini
#
[mypy-tools.render_junit]
warn_unused_ignores = False
[mypy-tools.generate_torch_version]
warn_unused_ignores = False
#
# Adding type annotations to caffe2 is probably not worth the effort
# only work on this if you have a specific reason for it, otherwise
# leave these ignores as they are.
#
[mypy-caffe2.python.*]
ignore_errors = True
[mypy-caffe2.proto.*]
ignore_errors = True
[mypy-caffe2.distributed.store_ops_test_util]
ignore_errors = True
[mypy-caffe2.experiments.*]
ignore_errors = True
[mypy-caffe2.contrib.*]
ignore_errors = True
[mypy-caffe2.quantization.server.*]
ignore_errors = True
#
# Third party dependencies that don't have types.
#
[mypy-triton.*]
ignore_missing_imports = True
[mypy-tensorflow.*]
ignore_missing_imports = True
[mypy-tensorboard.*]
ignore_missing_imports = True
[mypy-matplotlib.*]
ignore_missing_imports = True
[mypy-numpy.*]
ignore_missing_imports = True
[mypy-sympy]
ignore_missing_imports = True
[mypy-sympy.*]
ignore_missing_imports = True
[mypy-hypothesis.*]
ignore_missing_imports = True
[mypy-tqdm.*]
ignore_missing_imports = True
[mypy-multiprocessing.*]
ignore_missing_imports = True
[mypy-setuptools.*]
ignore_missing_imports = True
[mypy-distutils.*]
ignore_missing_imports = True
[mypy-nvd3.*]
ignore_missing_imports = True
[mypy-future.utils]
ignore_missing_imports = True
[mypy-past.builtins]
ignore_missing_imports = True
[mypy-numba.*]
ignore_missing_imports = True
[mypy-PIL.*]
ignore_missing_imports = True
[mypy-moviepy.*]
ignore_missing_imports = True
[mypy-cv2.*]
ignore_missing_imports = True
[mypy-torchvision.*]
ignore_missing_imports = True
[mypy-pycuda.*]
ignore_missing_imports = True
[mypy-tensorrt.*]
ignore_missing_imports = True
[mypy-tornado.*]
ignore_missing_imports = True
[mypy-pydot.*]
ignore_missing_imports = True
[mypy-networkx.*]
ignore_missing_imports = True
[mypy-scipy.*]
ignore_missing_imports = True
[mypy-IPython.*]
ignore_missing_imports = True
[mypy-google.protobuf.textformat]
ignore_missing_imports = True
[mypy-lmdb.*]
ignore_missing_imports = True
[mypy-mpi4py.*]
ignore_missing_imports = True
[mypy-skimage.*]
ignore_missing_imports = True
[mypy-librosa.*]
ignore_missing_imports = True
[mypy-mypy.*]
ignore_missing_imports = True
[mypy-xml.*]
ignore_missing_imports = True
[mypy-boto3.*]
ignore_missing_imports = True
[mypy-dill.*]
ignore_missing_imports = True
[mypy-usort.*]
ignore_missing_imports = True
[mypy-torch._inductor.*]
disallow_any_generics = True
[mypy-torch._dynamo.*]
disallow_any_generics = True
[mypy-cutlass_library.*]
ignore_missing_imports = True
[mypy-deeplearning.*]
ignore_missing_imports = True
[mypy-einops.*]
ignore_missing_imports = True
[mypy-libfb.*]
ignore_missing_imports = True
[mypy-torch.*.fb.*]
ignore_missing_imports = True
[mypy-torch.fb.*]
ignore_missing_imports = True
[mypy-torch_xla.*]
ignore_missing_imports = True
#
# Third party dependencies that are optional.
#
[mypy-onnx.*]
ignore_missing_imports = True
[mypy-onnxruntime.*]
ignore_missing_imports = True
[mypy-onnxscript.*]
ignore_missing_imports = True
[mypy-redis]
ignore_missing_imports = True