mypy warnings
This page explains some mypy warnings in the code that can be ignored.
Last updated: 2023-01-23, v0.2.0.
arg-typeerrors in:src/codepost_powertools/_utils/file_io.pysrc/codepost_powertools/rubric/rubric_to_sheet.pysrc/codepost_powertools/grading/ids.py
[file_io.py:137] Argument 3 to "handle_error" has incompatible type "Optional[str]"; expected "str" [rubric_to_sheet.py:766] Argument 1 to "_get_worksheets" has incompatible type "Optional[Spreadsheet]"; expected "Spreadsheet" [ids.py:151] Argument 2 to "save_csv" has incompatible type "Optional[Path]"; expected "Union[PathLike[Any], str]"
These errors involve the
SuccessOrNone[T]andSuccessOrErrorMsgtypes. They are defined as a tuple with a “success” flag and something else, with the types whensuccess = Trueand whensuccess = Falsedifferent but still exactly defined. Thus, if there is anifstatement checking the value ofsuccess, the other value’s type is definitely known within the body. However,mypydoes not recognize this, and gives errors.Additional conditionals can be put into the
ifstatements to also check if the other value isNone, but that would be redundant and only for the purpose of satisfying the type-checker. We have decided that that is not a good enough reason to change the code, and instead this error will remain. However, this means that more instances of this error will likely come up as more code is written.