Skip to content

Commit eff999b

Browse files
[FSSDK-13300] Remove dead Python 3.7 typing guards (#526)
* [FSSDK-13300] Remove dead Python 3.7 typing guards and pin mypy mypy 2.4.0 rejects the `if version_info < (3, 8)` conditional Protocol imports, failing type-check on every PR. Those branches only run on Python 3.7, which has been unsupported since 5.0, so import Final, Literal, Protocol and TypedDict directly from typing. Drop the mypy.ini unused-ignore override that existed only for the old TypedDict import, and pin mypy~=2.4.0 so new mypy releases can't break CI unannounced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [FSSDK-13300] Leave mypy unpinned Keep requirements/typing.txt as on master. The typing import cleanup alone fixes the mypy 2.4.0 failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2dc0ac1 commit eff999b

21 files changed

Lines changed: 24 additions & 149 deletions

‎mypy.ini‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@ exclude = (?x)(
99
)
1010
show_error_codes = True
1111
pretty = True
12-
13-
# suppress error on conditional import of typing_extensions module
14-
[mypy-optimizely.helpers.types]
15-
no_warn_unused_ignores = True

‎optimizely/bucketer.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@
1212
# limitations under the License.
1313

1414
from __future__ import annotations
15-
from typing import Optional, TYPE_CHECKING, cast
15+
from typing import Optional, TYPE_CHECKING, cast, Final
1616
import math
17-
from sys import version_info
1817

1918
from .lib import pymmh3 as mmh3
2019

2120

22-
if version_info < (3, 8):
23-
from typing_extensions import Final
24-
else:
25-
from typing import Final
26-
27-
2821
if TYPE_CHECKING:
2922
# prevent circular dependenacy by skipping import at runtime
3023
from .project_config import ProjectConfig

‎optimizely/decision/optimizely_decide_option.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
from sys import version_info
15-
16-
if version_info < (3, 8):
17-
from typing_extensions import Final
18-
else:
19-
from typing import Final
14+
from typing import Final
2015

2116

2217
class OptimizelyDecideOption:

‎optimizely/decision/optimizely_decision_message.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313

14-
from sys import version_info
15-
16-
if version_info < (3, 8):
17-
from typing_extensions import Final
18-
else:
19-
from typing import Final
14+
from typing import Final
2015

2116

2217
class OptimizelyDecisionMessage:

‎optimizely/entities.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
from __future__ import annotations
14-
from typing import TYPE_CHECKING, Any, Optional, Sequence
15-
from sys import version_info
16-
17-
if version_info < (3, 8):
18-
from typing_extensions import Final
19-
else:
20-
from typing import Final
14+
from typing import TYPE_CHECKING, Any, Optional, Sequence, Final
2115

2216

2317
if TYPE_CHECKING:

‎optimizely/event/event_factory.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# limitations under the License.
1313

1414
from __future__ import annotations
15-
from typing import TYPE_CHECKING, Optional, Sequence, cast, List
16-
from sys import version_info
15+
from typing import TYPE_CHECKING, Optional, Sequence, cast, List, Final
1716
from optimizely import entities
1817
from optimizely.helpers import enums
1918
from optimizely.helpers import event_tag_utils
@@ -23,11 +22,6 @@
2322
from . import payload
2423
from . import user_event
2524

26-
if version_info < (3, 8):
27-
from typing_extensions import Final
28-
else:
29-
from typing import Final
30-
3125
if TYPE_CHECKING:
3226
# prevent circular dependenacy by skipping import at runtime
3327
from optimizely.project_config import ProjectConfig

‎optimizely/event/event_processor.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
import threading
1818
import time
1919

20-
from typing import Optional
20+
from typing import Optional, Final
2121
from datetime import timedelta
2222
import queue
23-
from sys import version_info
2423

2524
from optimizely import logger as _logging
2625
from optimizely import notification_center as _notification_center
@@ -31,12 +30,6 @@
3130
from .user_event import UserEvent
3231

3332

34-
if version_info < (3, 8):
35-
from typing_extensions import Final
36-
else:
37-
from typing import Final
38-
39-
4033
class BaseEventProcessor(ABC):
4134
""" Class encapsulating event processing. Override with your own implementation. """
4235

‎optimizely/event/log_event.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,10 @@
1212
# limitations under the License.
1313

1414
from __future__ import annotations
15-
from typing import Optional, Any
16-
from sys import version_info
15+
from typing import Optional, Any, Literal
1716
from optimizely import event_builder
1817

1918

20-
if version_info < (3, 8):
21-
from typing_extensions import Literal
22-
else:
23-
from typing import Literal
24-
25-
2619
class LogEvent(event_builder.Event):
2720
""" Representation of an event which can be sent to Optimizely events API. """
2821

‎optimizely/event/user_event.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@
1313
from __future__ import annotations
1414
import time
1515
import uuid
16-
from typing import TYPE_CHECKING, Optional
17-
from sys import version_info
16+
from typing import TYPE_CHECKING, Optional, Final
1817

1918
from optimizely import version
2019

2120

22-
if version_info < (3, 8):
23-
from typing_extensions import Final
24-
else:
25-
from typing import Final
26-
27-
2821
if TYPE_CHECKING:
2922
# prevent circular dependenacy by skipping import at runtime
3023
from optimizely.entities import Experiment, Variation, Event, Holdout

‎optimizely/event_builder.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,15 @@
1313

1414
from __future__ import annotations
1515
import time
16-
from typing import TYPE_CHECKING, Any, Optional
16+
from typing import TYPE_CHECKING, Any, Optional, Final, Literal
1717
import uuid
18-
from sys import version_info
1918

2019
from . import version
2120
from .event import event_id_normalizer
2221
from .helpers import enums
2322
from .helpers import event_tag_utils
2423
from .helpers import validator
2524

26-
if version_info < (3, 8):
27-
from typing_extensions import Final, Literal
28-
else:
29-
from typing import Final, Literal
30-
3125
if TYPE_CHECKING:
3226
# prevent circular dependenacy by skipping import at runtime
3327
from .entities import Experiment

0 commit comments

Comments
 (0)