diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-01-17 14:11:10 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-01-17 14:11:10 +0100 |
commit | 0ab0f71ec113c4a8d32947f3482470f8ae7c842e (patch) | |
tree | 86eb63330ea7b13a53b840d16a52702276dcb415 | |
parent | 0d64ae3fe33663d5ee536a53d15b21763b73e488 (diff) | |
download | qutebrowser-0ab0f71ec113c4a8d32947f3482470f8ae7c842e.tar.gz qutebrowser-0ab0f71ec113c4a8d32947f3482470f8ae7c842e.zip |
rfc6266: Fix mypy
See https://github.com/python/typeshed/issues/4941
-rw-r--r-- | qutebrowser/browser/webkit/rfc6266.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/qutebrowser/browser/webkit/rfc6266.py b/qutebrowser/browser/webkit/rfc6266.py index 82ab29c7f..1c1cffaa6 100644 --- a/qutebrowser/browser/webkit/rfc6266.py +++ b/qutebrowser/browser/webkit/rfc6266.py @@ -37,11 +37,14 @@ class DefectWrapper: """Wrapper around a email.error for comparison.""" - error_class: Type[email.errors.MessageError] + error_class: Type[email.errors.MessageDefect] line: str def __eq__(self, other): - return isinstance(other, self.error_class) and other.line == self.line + return ( + isinstance(other, self.error_class) + and other.line == self.line # type: ignore[attr-defined] + ) class _ContentDisposition: @@ -91,7 +94,7 @@ class _ContentDisposition: # which has a slightly different wording ("duplicate(s) ignored" instead of "duplicate # ignored"), because even if we did ignore that one, it still wouldn't work properly... _IGNORED_DEFECT = DefectWrapper( - email.errors.InvalidHeaderDefect, + email.errors.InvalidHeaderDefect, # type: ignore[attr-defined] 'duplicate parameter name; duplicate ignored' ) @@ -114,8 +117,9 @@ def parse_headers(content_disposition): if parsed.defects: defects = list(parsed.defects) - if defects != [_IGNORED_DEFECT]: + if defects != [_IGNORED_DEFECT]: # type: ignore[comparison-overlap] raise Error(defects) + assert isinstance(parsed, email.headerregistry.ContentDispositionHeader), parsed return _ContentDisposition(disposition=parsed.content_disposition, params=parsed.params) |