|
| 1 | +{ |
| 2 | + // 校准配置:让编辑器只报「真问题」,而不是基于默认推荐规则产生大量噪音。 |
| 3 | + // 背景:仓库此前没有 pyright/basedpyright 配置,basedpyright 使用自身默认 |
| 4 | + // (相当于 recommended),在 app/ 下产生 247 errors / 3799 warnings,其中 |
| 5 | + // 143 条是 reportMissingTypeArgument(未参数化泛型,如 Task / Result / ColumnElement), |
| 6 | + // 属「注解完整度」而非缺陷,会掩盖 reportArgumentType / reportAttributeAccessIssue |
| 7 | + // 这类能抓到真 bug 的规则(例如 OSS 的 Client.uploader 方法误用)。 |
| 8 | + "typeCheckingMode": "basic", |
| 9 | + "pythonVersion": "3.12", |
| 10 | + "venvPath": ".", |
| 11 | + "venv": ".venv", |
| 12 | + "include": ["app", "main.py", "tests"], |
| 13 | + "exclude": ["**/__pycache__", ".venv", ".mypy_cache", ".ruff_cache", "alembic/versions"], |
| 14 | + |
| 15 | + // tests/ 单独放宽:测试普遍用 SimpleNamespace 假对象、从 fixture 取 Optional 后直接使用, |
| 16 | + // 这些由 pytest 运行期验证;对 app/ 的严格规则保持不变。 |
| 17 | + "executionEnvironments": [ |
| 18 | + { |
| 19 | + "root": "tests", |
| 20 | + "extraPaths": ["."], |
| 21 | + "reportArgumentType": "none", |
| 22 | + "reportCallIssue": "none", |
| 23 | + "reportOptionalSubscript": "none", |
| 24 | + "reportOptionalMemberAccess": "none", |
| 25 | + "reportOperatorIssue": "none", |
| 26 | + "reportUnusedCallResult": "none" |
| 27 | + }, |
| 28 | + { |
| 29 | + "root": "." |
| 30 | + } |
| 31 | + ], |
| 32 | + |
| 33 | + // ── 保留为 error(能抓真缺陷,不允许降级)── |
| 34 | + "reportAttributeAccessIssue": "error", |
| 35 | + "reportArgumentType": "error", |
| 36 | + "reportAssignmentType": "error", |
| 37 | + "reportCallIssue": "error", |
| 38 | + "reportReturnType": "error", |
| 39 | + "reportGeneralTypeIssues": "error", |
| 40 | + "reportOptionalMemberAccess": "error", |
| 41 | + "reportOptionalCall": "error", |
| 42 | + "reportOptionalSubscript": "error", |
| 43 | + "reportOptionalIterable": "error", |
| 44 | + "reportOptionalOperand": "error", |
| 45 | + "reportIndexIssue": "error", |
| 46 | + "reportOperatorIssue": "error", |
| 47 | + "reportInvalidTypeArguments": "error", |
| 48 | + "reportConstantRedefinition": "error", |
| 49 | + "reportRedeclaration": "error", |
| 50 | + "reportUndefinedVariable": "error", |
| 51 | + "reportSelfClsParameterName": "error", |
| 52 | + "reportInvalidStringEscapeSequence": "error", |
| 53 | + "reportUnhashable": "error", |
| 54 | + "reportInvalidCast": "error", |
| 55 | + "reportAssertAlwaysTrue": "error", |
| 56 | + "reportIncompatibleMethodOverride": "error", |
| 57 | + "reportOverlappingOverload": "error", |
| 58 | + "reportNoOverloadImplementation": "error", |
| 59 | + "reportAbstractUsage": "error", |
| 60 | + "reportMissingImports": "error", |
| 61 | + "reportMissingModuleSource": "warning", |
| 62 | + |
| 63 | + // SQLAlchemy 声明式模型的已知误报族:基类用 @declared_attr.directive 生成 |
| 64 | + // __tablename__/__table_args__(pyright 视作描述符/类变量),而各模型普遍用普通 |
| 65 | + // 类属性覆写(__tablename__: str = "sys_user"),pyright 判定为「实例变量覆写类变量」。 |
| 66 | + // 试过在基类 TYPE_CHECKING 里补 ClassVar 声明的正规解法:反而新增 reportRedeclaration |
| 67 | + // 且错误数上升(62 → 90),故按社区通行做法关闭该规则。真实的方法覆写不兼容由 |
| 68 | + // reportIncompatibleMethodOverride(保持 error)兜底。 |
| 69 | + "reportIncompatibleVariableOverride": "none", |
| 70 | + "reportUnboundVariable": "error", |
| 71 | + |
| 72 | + // ── 降级为 none:注解完整度/风格类,属增量清理而非缺陷 ── |
| 73 | + "reportMissingTypeArgument": "none", |
| 74 | + "reportUnknownMemberType": "none", |
| 75 | + "reportUnknownArgumentType": "none", |
| 76 | + "reportUnknownVariableType": "none", |
| 77 | + "reportUnknownParameterType": "none", |
| 78 | + "reportUnknownLambdaType": "none", |
| 79 | + "reportMissingParameterType": "none", |
| 80 | + "reportUnannotatedClassAttribute": "none", |
| 81 | + "reportImplicitOverride": "none", |
| 82 | + "reportMissingTypeStubs": "none", |
| 83 | + "reportAny": "none", |
| 84 | + "reportExplicitAny": "none", |
| 85 | + "reportUnusedCallResult": "none", |
| 86 | + "reportUnusedImport": "none", |
| 87 | + "reportPrivateImportUsage": "none", |
| 88 | + "reportPrivateLocalImportUsage": "none", |
| 89 | + "reportUnnecessaryComparison": "none", |
| 90 | + "reportUnnecessaryIsInstance": "none", |
| 91 | + "reportUnnecessaryCast": "none", |
| 92 | + "reportUnusedParameter": "none", |
| 93 | + "reportUnreachable": "none", |
| 94 | + "reportImplicitStringConcatenation": "none", |
| 95 | + "reportUnsafeMultipleInheritance": "none", |
| 96 | + "reportDeprecated": "none", |
| 97 | + "reportUnusedClass": "none", |
| 98 | + "reportUnusedFunction": "none", |
| 99 | + "reportUnusedVariable": "none", |
| 100 | + "reportWildcardImportFromLibrary": "none", |
| 101 | + "reportUnsupportedDunderAll": "none" |
| 102 | +} |
0 commit comments