summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog13
-rw-r--r--debian/control1
-rw-r--r--debian/copyright2
-rwxr-xr-xemail-print-mime-structure22
-rwxr-xr-ximap-dl14
-rw-r--r--mailscripts.el2
6 files changed, 37 insertions, 17 deletions
diff --git a/debian/changelog b/debian/changelog
index 1ecdf0b..31a35fc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,13 @@
-mailscripts (28-1) UNRELEASED; urgency=medium
+mailscripts (29-1) unstable; urgency=medium
+
+ * Clean up types for mypy 1.9.0 (Closes: #1067796).
+ Thanks to Daniel Kahn Gillmor for the patch.
+ - New build-dep on python3-gssapi.
+ - Update copyright years for dkg.
+
+ -- Sean Whitton <spwhitton@spwhitton.name> Sat, 06 Apr 2024 16:23:46 +0800
+
+mailscripts (28-1) unstable; urgency=medium
* mailscripts.el:
- new commands: mailscripts-git-format-patch-{attach,drafts,append}
@@ -21,7 +30,7 @@ mailscripts (28-1) UNRELEASED; urgency=medium
* Add & install a README, to both binary packages.
* Tighten build-dep on python3-pgpy to require >= 0.5.4-4.1.
- -- Sean Whitton <spwhitton@spwhitton.name> Sun, 18 Dec 2022 10:40:55 -0700
+ -- Sean Whitton <spwhitton@spwhitton.name> Sat, 24 Dec 2022 12:09:07 -0700
mailscripts (27-1) unstable; urgency=medium
diff --git a/debian/control b/debian/control
index a85a1b6..31187e3 100644
--- a/debian/control
+++ b/debian/control
@@ -16,6 +16,7 @@ Build-Depends:
perl,
python3 <!nocheck>,
python3-argcomplete,
+ python3-gssapi <!nocheck>,
python3-pgpy (>= 0.5.4-4.1) <!nocheck>,
Vcs-Git: https://git.spwhitton.name/mailscripts
Vcs-Browser: https://git.spwhitton.name/mailscripts
diff --git a/debian/copyright b/debian/copyright
index f4fee59..ac4c52e 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -2,7 +2,7 @@ mailscripts
Collection of scripts for manipulating e-mail on Debian
Copyright (C)2017-2021 Sean Whitton
-Copyright (C)2019-2020 Daniel Kahn Gillmor
+Copyright (C)2019-2024 Daniel Kahn Gillmor
Copyright (C)2020 Red Hat, Inc.
Copyright (C)2022 Jameson Graef Rollins
diff --git a/email-print-mime-structure b/email-print-mime-structure
index b7646e0..3263da9 100755
--- a/email-print-mime-structure
+++ b/email-print-mime-structure
@@ -2,7 +2,7 @@
# PYTHON_ARGCOMPLETE_OK
# -*- coding: utf-8 -*-
-# Copyright (C) 2019 Daniel Kahn Gillmor
+# Copyright (C) 2019-2024 Daniel Kahn Gillmor
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -39,6 +39,7 @@ import subprocess
from argparse import ArgumentParser, Namespace
from typing import Optional, Union, List, Tuple, Any
+from types import ModuleType
from email.charset import Charset
from email.message import Message
@@ -47,8 +48,9 @@ try:
except ImportError:
pgpy = None
+argcomplete:Optional[ModuleType]
try:
- import argcomplete #type: ignore
+ import argcomplete
except ImportError:
argcomplete = None
@@ -74,7 +76,7 @@ class MimePrinter(object):
# FIXME: it looks like we are counting chars here, not bytes:
nbytes = len(z.as_string())
else:
- payload:Union[List[Message], str, bytes, None] = z.get_payload()
+ payload = z.get_payload()
if not isinstance(payload, (str,bytes)):
raise TypeError(f'expected payload to be either str or bytes, got {type(payload)}')
# FIXME: it looks like we are counting chars here, not bytes:
@@ -106,7 +108,7 @@ class MimePrinter(object):
else:
if z.get_content_type().lower() == 'application/pkcs7-mime' and \
str(z.get_param('smime-type')).lower() == 'signed-data':
- bodypart:Union[List[Message],str,bytes,None] = z.get_payload(decode=True)
+ bodypart = z.get_payload(decode=True)
if isinstance(bodypart, bytes):
unwrapped = self.pipe_transform(bodypart, ['certtool', '--p7-show-data', '--p7-info', '--inder'])
if unwrapped:
@@ -118,7 +120,7 @@ class MimePrinter(object):
def decrypt_part(self, msg:Message, flavor:EncType) -> Optional[Message]:
- ciphertext:Union[List[Message],str,bytes,None] = msg.get_payload(decode=True)
+ ciphertext = msg.get_payload(decode=True)
cryptopayload:Optional[Message] = None
if not isinstance(ciphertext, bytes):
logging.warning('encrypted part was not a leaf mime part somehow')
@@ -178,14 +180,18 @@ class MimePrinter(object):
prefix = prefix.rpartition('└')[0] + ' '
if prefix.endswith('├'):
prefix = prefix.rpartition('├')[0] + '│'
- parts:Union[List[Message], str, bytes, None] = z.get_payload()
+ parts = z.get_payload()
if not isinstance(parts, list):
raise TypeError(f'parts was {type(parts)}, expected List[Message]')
i = 0
while (i < len(parts)-1):
- self.print_tree(parts[i], prefix + '├', z, i+1)
+ msg = parts[i]
+ if isinstance(msg, Message):
+ self.print_tree(msg, prefix + '├', z, i+1)
i += 1
- self.print_tree(parts[i], prefix + '└', z, i+1)
+ msg = parts[i]
+ if isinstance(msg, Message):
+ self.print_tree(msg, prefix + '└', z, i+1)
# FIXME: show epilogue?
else:
self.print_part(z, prefix+'─╴', parent, num)
diff --git a/imap-dl b/imap-dl
index fac7487..824c21d 100755
--- a/imap-dl
+++ b/imap-dl
@@ -2,7 +2,7 @@
# PYTHON_ARGCOMPLETE_OK
# -*- coding: utf-8 -*-
-# Copyright (C) 2019-2020 Daniel Kahn Gillmor
+# Copyright (C) 2019-2024 Daniel Kahn Gillmor
# Copyright (C) 2020 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or modify
@@ -52,14 +52,17 @@ import statistics
import configparser
from typing import Dict, List, Optional, Tuple, Union
+from types import ModuleType
+argcomplete:Optional[ModuleType]
try:
- import argcomplete #type: ignore
+ import argcomplete
except ImportError:
argcomplete = None
+gssapi:Optional[ModuleType]
try:
- import gssapi # type: ignore
+ import gssapi
except ModuleNotFoundError:
gssapi = None
@@ -96,15 +99,16 @@ def auth_builtin(username:str, imap:imaplib.IMAP4,
except Exception as e:
raise Exception(f'login failed with {e} as user {username} on {server}')
-if gssapi:
+if gssapi is not None:
# imaplib auth methods need to be in the form of callables, and they all
# requre both additional parameters and storage beyond what the function
# interface provides.
class GSSAPI_handler():
- gss_vc:gssapi.SecurityContext
username:str
def __init__(self, server:str, username:str) -> None:
+ if gssapi is None:
+ raise Exception("Impossible state -- gssapi module is not loaded")
name = gssapi.Name(f'imap@{server}',
gssapi.NameType.hostbased_service)
self.gss_vc = gssapi.SecurityContext(usage="initiate", name=name)
diff --git a/mailscripts.el b/mailscripts.el
index 32187df..15c135f 100644
--- a/mailscripts.el
+++ b/mailscripts.el
@@ -1,7 +1,7 @@
;;; mailscripts.el --- utilities for handling mail on Unixes -*- lexical-binding: t; -*-
;; Author: Sean Whitton <spwhitton@spwhitton.name>
-;; Version: 27
+;; Version: 28
;; Package-Requires: (notmuch)
;; Copyright (C) 2018, 2019, 2020, 2022 Sean Whitton