capa: fix mypy 1.1.1 fails


Run mypy --config-file .github/mypy/mypy.ini --check-untyped-defs capa/ scripts/ tests/
capa/features/freeze/features.py:104: error: Argument "os" to "OSFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:107: error: Argument "arch" to "ArchFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:110: error: Argument "format" to "FormatFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:113: error: Argument "match" to "MatchFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:116: error: Argument "characteristic" to "CharacteristicFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:119: error: Argument "export" to "ExportFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:122: error: Unexpected keyword argument "import_" for "ImportFeature"; did you mean "import"?  [call-arg]
capa/features/freeze/features.py:125: error: Argument "section" to "SectionFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:128: error: Unexpected keyword argument "function_name" for "FunctionNameFeature"; did you mean "function name"?  [call-arg]
capa/features/freeze/features.py:132: error: Argument "substring" to "SubstringFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:136: error: Argument "regex" to "RegexFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:139: error: Argument "string" to "StringFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:142: error: Unexpected keyword argument "class_" for "ClassFeature"; did you mean "class"?  [call-arg]
capa/features/freeze/features.py:145: error: Argument "namespace" to "NamespaceFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:151: error: Argument "api" to "APIFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:154: error: Argument "property" to "PropertyFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:157: error: Argument "number" to "NumberFeature" has incompatible type "Union[str, int, float, bytes]"; expected "Union[int, float]"  [arg-type]
capa/features/freeze/features.py:165: error: Argument "offset" to "OffsetFeature" has incompatible type "Union[str, int, float, bytes]"; expected "int"  [arg-type]
capa/features/freeze/features.py:168: error: Argument "mnemonic" to "MnemonicFeature" has incompatible type "Union[str, int, float, bytes]"; expected "str"  [arg-type]
capa/features/freeze/features.py:171: error: Unexpected keyword argument "operand_number" for "OperandNumberFeature"; did you mean "operand number"?  [call-arg]
capa/features/freeze/features.py:174: error: Unexpected keyword argument "operand_offset" for "OperandOffsetFeature"; did you mean "operand offset"?  [call-arg]
capa/features/freeze/__init__.py:267: error: Unexpected keyword argument "basic_block" for "BasicBlockFeature"; did you mean "basic block"?  [call-arg]
capa/features/freeze/__init__.py:290: error: Argument "features" to "InstructionFeatures" has incompatible type "List[InstructionFeature]"; expected "Tuple[InstructionFeature, ...]"  [arg-type]
capa/features/freeze/__init__.py:297: error: Argument "features" to "BasicBlockFeatures" has incompatible type "List[BasicBlockFeature]"; expected "Tuple[BasicBlockFeature, ...]"  [arg-type]
capa/features/freeze/__init__.py:298: error: Argument "instructions" to "BasicBlockFeatures" has incompatible type "List[InstructionFeatures]"; expected "Tuple[InstructionFeatures, ...]"  [arg-type]
capa/features/freeze/__init__.py:303: error: Unexpected keyword argument "basic_blocks" for "FunctionFeatures"; did you mean "basic blocks"?  [call-arg]
capa/features/freeze/__init__.py:305: error: Argument "features" to "FunctionFeatures" has incompatible type "List[FunctionFeature]"; expected "Tuple[FunctionFeature, ...]"  [arg-type]
capa/features/freeze/__init__.py:310: error: Unexpected keyword argument "global_" for "Features"; did you mean "global"?  [call-arg]
capa/features/freeze/__init__.py:312: error: Argument "file" to "Features" has incompatible type "List[FileFeature]"; expected "Tuple[FileFeature, ...]"  [arg-type]
capa/features/freeze/__init__.py:313: error: Argument "functions" to "Features" has incompatible type "List[FunctionFeatures]"; expected "Tuple[FunctionFeatures, ...]"  [arg-type]
capa/features/freeze/__init__.py:316: error: Unexpected keyword argument "base_address" for "Freeze"; did you mean "base address"?  [call-arg]
capa/render/result_document.py:356: error: Argument "children" to "Match" has incompatible type "List[Match]"; expected "Tuple[Match, ...]"  [arg-type]
capa/render/result_document.py:357: error: Argument "locations" to "Match" has incompatible type "List[Address]"; expected "Tuple[Address, ...]"  [arg-type]
capa/render/result_document.py:358: error: Argument "captures" to "Match" has incompatible type "Dict[str, List[Address]]"; expected "Dict[str, Tuple[Address, ...]]"  [arg-type]
capa/render/result_document.py:482: error: Unexpected keyword argument "attack" for "RuleMetadata"; did you mean "att&ck"?  [call-arg]
capa/render/result_document.py:482: error: Unexpected keyword argument "capa_subscope" for "RuleMetadata"; did you mean "capa/subscope"?  [call-arg]
capa/render/result_document.py:488: error: Argument "mbc" to "RuleMetadata" has incompatible type "List[MBCSpec]"; expected "Tuple[MBCSpec, ...]"  [arg-type]
capa/render/result_document.py:494: error: Unexpected keyword argument "analysis_conclusion" for "MaecMetadata"; did you mean "analysis-conclusion" or "analysis-conclusion-ov"?  [call-arg]
capa/render/result_document.py:494: error: Unexpected keyword argument "analysis_conclusion_ov" for "MaecMetadata"; did you mean "analysis-conclusion-ov" or "analysis-conclusion"?  [call-arg]
capa/render/result_document.py:494: error: Unexpected keyword argument "malware_family" for "MaecMetadata"; did you mean "malware-family"?  [call-arg]
capa/render/result_document.py:494: error: Unexpected keyword argument "malware_category" for "MaecMetadata"; did you mean "malware-category" or "malware-category-ov"?  [call-arg]
capa/render/result_document.py:494: error: Unexpected keyword argument "malware_category_ov" for "MaecMetadata"; did you mean "malware-category-ov" or "malware-category"?  [call-arg]
Found 42 errors in 3 files (checked 112 source files)

ref: #1381

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

sidebar: i wish there was a way to tag fixes like this to be re-reviewed in 6 months or so. maybe we could introduce a convention like # TODO(2023-06): review mypy override and periodically grep the code for things to be re-assessed. thoughts @mr-tz @mike-hunhoff

cool, idea! I think we already have a few TODO places that can benefit from such an annotation (and regular check, which would be cool to flag via an Action or similar).