Skip to content

Commit 3656229

Browse files
fixed some type hints
1 parent b634471 commit 3656229

26 files changed

+39
-106
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="sifter3",
13-
version="0.2.5",
13+
version="0.2.6",
1414
author="Manfred Kaiser, Gary Peck",
1515
1616
url="https://sifter3.readthedocs.io/en/latest/",

sifter/commands/discard.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
from email.message import Message
2-
from typing import (
3-
Optional
4-
)
52

6-
from sifter.grammar.actions import Actions
73
from sifter.grammar.state import EvaluationState
84
from sifter.grammar.command import Command
95

@@ -13,6 +9,5 @@ class CommandDiscard(Command):
139

1410
HANDLER_ID = 'DISCARD'
1511

16-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
12+
def evaluate(self, message: Message, state: EvaluationState) -> None:
1713
state.actions.cancel_implicit_keep()
18-
return None

sifter/commands/fileinto.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
from email.message import Message
2-
from typing import (
3-
Optional
4-
)
52

63
from sifter.grammar.command import Command
74
from sifter.grammar.string import expand_variables
85
from sifter.validators.stringlist import StringList
96
from sifter.grammar.state import EvaluationState
10-
from sifter.grammar.actions import Actions
117

128

139
# section 4.1
@@ -17,12 +13,11 @@ class CommandFileInto(Command):
1713
EXTENSION_NAME = 'fileinto'
1814
POSITIONAL_ARGS = [StringList(length=1)]
1915

20-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
16+
def evaluate(self, message: Message, state: EvaluationState) -> None:
2117
state.check_required_extension('fileinto', 'FILEINTO')
2218

2319
file_dest = self.positional_args[0]
2420
file_dest = list(map(lambda s: expand_variables(s, state), file_dest)) # type: ignore
2521

2622
state.actions.append('fileinto', file_dest)
2723
state.actions.cancel_implicit_keep()
28-
return None

sifter/commands/imap4flags.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from email.message import Message
2-
from typing import Optional
32

43
from sifter.grammar.command import Command
54
from sifter.validators.stringlist import StringList
65
from sifter.grammar.string import expand_variables
76
from sifter.grammar.state import EvaluationState
8-
from sifter.grammar.actions import Actions
97

108
# This implements the RFC5232 imap4flags extension
119
# commands: addflag, removeflag, setflag
@@ -19,12 +17,11 @@ class CommandSetFlag(Command):
1917
EXTENSION_NAME = 'imap4flags'
2018
POSITIONAL_ARGS = [StringList()]
2119

22-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
20+
def evaluate(self, message: Message, state: EvaluationState) -> None:
2321
state.check_required_extension('imap4flags', 'imapflags')
2422
flag_list = self.positional_args[0]
2523
flag_list = list(map(lambda s: expand_variables(s, state), flag_list)) # type: ignore
2624
state.actions.append('setflag', flag_list)
27-
return None
2825

2926

3027
class CommandRemoveFlag(Command):
@@ -33,12 +30,11 @@ class CommandRemoveFlag(Command):
3330
EXTENSION_NAME = 'imap4flags'
3431
POSITIONAL_ARGS = [StringList()]
3532

36-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
33+
def evaluate(self, message: Message, state: EvaluationState) -> None:
3734
state.check_required_extension('imap4flags', 'imapflags')
3835
flag_list = self.positional_args[0]
3936
flag_list = list(map(lambda s: expand_variables(s, state), flag_list)) # type: ignore
4037
state.actions.append('removeflag', flag_list)
41-
return None
4238

4339

4440
class CommandAddFlag(Command):
@@ -47,9 +43,8 @@ class CommandAddFlag(Command):
4743
EXTENSION_NAME = 'imap4flags'
4844
POSITIONAL_ARGS = [StringList()]
4945

50-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
46+
def evaluate(self, message: Message, state: EvaluationState) -> None:
5147
state.check_required_extension('imap4flags', 'imapflags')
5248
flag_list = self.positional_args[0]
5349
flag_list = list(map(lambda s: expand_variables(s, state), flag_list)) # type: ignore
5450
state.actions.append('addflag', flag_list)
55-
return None

sifter/commands/keep.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
from email.message import Message
2-
from typing import (
3-
Optional
4-
)
52

63
from sifter.grammar.command import Command
74
from sifter.grammar.state import EvaluationState
8-
from sifter.grammar.actions import Actions
95

106

117
# section 4.3
@@ -14,7 +10,6 @@ class CommandKeep(Command):
1410
HANDLER_ID = 'KEEP'
1511
HAS_BLOCKS = False
1612

17-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
13+
def evaluate(self, message: Message, state: EvaluationState) -> None:
1814
state.actions.append('keep')
1915
state.actions.cancel_implicit_keep()
20-
return None

sifter/commands/notify.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
from email.message import Message
3-
from typing import Optional
43

54
from sifter.grammar.command import Command
65
from sifter.grammar.string import expand_variables
@@ -9,7 +8,6 @@
98
from sifter.grammar.rule import RuleSyntaxError
109
from sifter.extensions import ExtensionRegistry
1110
from sifter.grammar.state import EvaluationState
12-
from sifter.grammar.actions import Actions
1311

1412

1513
# RFC 5435
@@ -27,7 +25,7 @@ class CommandNotify(Command):
2725
StringList(length=1)
2826
]
2927

30-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
28+
def evaluate(self, message: Message, state: EvaluationState) -> None:
3129
notify_from = notify_importance = self.notify_message = None
3230
notify_options = [] # type: ignore
3331
if 'from' in self.tagged_args:
@@ -64,5 +62,3 @@ def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions
6462
'notify',
6563
(notify_method, notify_from, notify_importance, notify_options, notify_message) # type: ignore
6664
)
67-
68-
return None

sifter/commands/redirect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from sifter.grammar.rule import RuleSyntaxError
1515
from sifter.validators.stringlist import StringList
1616
from sifter.grammar.state import EvaluationState
17-
from sifter.grammar.actions import Actions
1817
from sifter.grammar.string import expand_variables
1918

2019
if TYPE_CHECKING:
@@ -49,8 +48,7 @@ def __init__(
4948
% self.email_address
5049
)
5150

52-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
51+
def evaluate(self, message: Message, state: EvaluationState) -> None:
5352
email_address = expand_variables(self.email_address, state)
5453
state.actions.append('redirect', email_address)
5554
state.actions.cancel_implicit_keep()
56-
return None

sifter/commands/reject.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from email.message import Message
22
from typing import (
3-
Text,
4-
Optional
3+
Text
54
)
65

76
from sifter.grammar.command import Command
87
from sifter.validators.stringlist import StringList
98
from sifter.grammar.state import EvaluationState
10-
from sifter.grammar.actions import Actions
119

1210

1311
# section 3.2
@@ -17,11 +15,10 @@ class CommandReject(Command):
1715
EXTENSION_NAME = 'reject'
1816
POSITIONAL_ARGS = [StringList()]
1917

20-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
18+
def evaluate(self, message: Message, state: EvaluationState) -> None:
2119
reject_message = self.positional_args[0][0] # type: ignore
2220
state.actions.append('reject', reject_message)
2321
state.actions.cancel_implicit_keep()
24-
return None
2522

2623

2724
class CommandEReject(CommandReject):

sifter/commands/require.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from email.message import Message
22
from typing import (
3-
Text,
4-
Optional
3+
Text
54
)
65

76
from sifter.grammar.command import Command
87
from sifter.extensions import ExtensionRegistry
98
from sifter.validators.stringlist import StringList
109
from sifter.grammar.state import EvaluationState
11-
from sifter.grammar.actions import Actions
1210

1311

1412
# section 3.2
@@ -17,7 +15,7 @@ class CommandRequire(Command):
1715
HANDLER_ID: Text = 'REQUIRE'
1816
POSITIONAL_ARGS = [StringList()]
1917

20-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
18+
def evaluate(self, message: Message, state: EvaluationState) -> None:
2119
ext_name_list = self.positional_args[0]
2220
for ext_name in ext_name_list: # type: ignore
2321
if not ExtensionRegistry.has_extension(ext_name):
@@ -26,4 +24,3 @@ def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions
2624
% ext_name
2725
)
2826
state.require_extension(ext_name)
29-
return None

sifter/commands/stop.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
from email.message import Message
2-
from typing import (
3-
Optional
4-
)
52

63
from sifter.grammar.command import Command
74
from sifter.grammar.state import EvaluationState
8-
from sifter.grammar.actions import Actions
95

106

117
# section 3.3
128
class CommandStop(Command):
139

1410
HANDLER_ID = 'STOP'
1511

16-
def evaluate(self, message: Message, state: EvaluationState) -> Optional[Actions]:
12+
def evaluate(self, message: Message, state: EvaluationState) -> None:
1713
state.actions.append('stop')
18-
return None

0 commit comments

Comments
 (0)