Skip to content

Commit 3890a37

Browse files
committed
making pytz not a requirement
1 parent f86189e commit 3890a37

File tree

6 files changed

+33
-10
lines changed

6 files changed

+33
-10
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# DeepDiff Change log
22

3+
- v8-4-1
4+
- Adding BaseOperatorPlus base class for custom operators
5+
- default_timezone can be passed now to set your default timezone to something other than UTC.
6+
- New summarization algorithm that produces valid json
7+
- Better type hint support
8+
- Breaking change in DeepHash where we raise Exception instead of logging if we can't hash a value.
9+
310
- v8-3-0
411
- Fixed some static typing issues
512
- Added the summarize module for better repr of nested values

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ Tested on Python 3.8+ and PyPy3.
2323

2424
Please check the [ChangeLog](CHANGELOG.md) file for the detailed information.
2525

26-
DeepDiff 8-4-0
26+
DeepDiff 8-4-1
2727

2828
- Adding BaseOperatorPlus base class for custom operators
2929
- default_timezone can be passed now to set your default timezone to something other than UTC.
3030
- New summarization algorithm that produces valid json
3131
- Better type hint support
32+
- Breaking change in DeepHash where we raise Exception instead of logging if we can't hash a value.
3233

3334
DeepDiff 8-3-0
3435

deepdiff/deephash.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env python
2-
import pytz
32
import logging
43
import datetime
5-
from typing import Union, Optional, Any, List
4+
from typing import Union, Optional, Any, List, TYPE_CHECKING
65
from collections.abc import Iterable, MutableMapping
76
from collections import defaultdict
87
from hashlib import sha1, sha256
@@ -17,6 +16,10 @@
1716

1817
from deepdiff.base import Base
1918

19+
if TYPE_CHECKING:
20+
from pytz.tzinfo import BaseTzInfo
21+
22+
2023
try:
2124
import pandas
2225
except ImportError:
@@ -143,7 +146,7 @@ def __init__(self,
143146
*,
144147
apply_hash=True,
145148
custom_operators: Optional[List[Any]] =None,
146-
default_timezone:Union[datetime.timezone, datetime.timezone, pytz.tzinfo.BaseTzInfo]=datetime.timezone.utc,
149+
default_timezone:Union[datetime.timezone, "BaseTzInfo"]=datetime.timezone.utc,
147150
encodings=None,
148151
exclude_obj_callback=None,
149152
exclude_paths=None,

deepdiff/diff.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
# You might need to run it many times since dictionaries come in different orders
66
# every time you run the docstrings.
77
# However the docstring expects it in a specific order in order to pass!
8-
import pytz
98
import difflib
109
import logging
1110
import types
1211
import datetime
1312
from enum import Enum
1413
from copy import deepcopy
1514
from math import isclose as is_close
16-
from typing import List, Dict, Callable, Union, Any, Pattern, Tuple, Optional, Set, FrozenSet
15+
from typing import List, Dict, Callable, Union, Any, Pattern, Tuple, Optional, Set, FrozenSet, TYPE_CHECKING
1716
from collections.abc import Mapping, Iterable, Sequence
1817
from collections import defaultdict
1918
from inspect import getmembers
@@ -42,6 +41,10 @@
4241
from deepdiff.base import Base
4342
from deepdiff.lfucache import LFUCache, DummyLFU
4443

44+
if TYPE_CHECKING:
45+
from pytz.tzinfo import BaseTzInfo
46+
47+
4548
logger = logging.getLogger(__name__)
4649

4750
MAX_PASSES_REACHED_MSG = (
@@ -131,7 +134,7 @@ def __init__(self,
131134
custom_operators: Optional[List[Any]] =None,
132135
cutoff_distance_for_pairs: float=CUTOFF_DISTANCE_FOR_PAIRS_DEFAULT,
133136
cutoff_intersection_for_pairs: float=CUTOFF_INTERSECTION_FOR_PAIRS_DEFAULT,
134-
default_timezone:Union[datetime.timezone, datetime.timezone, pytz.tzinfo.BaseTzInfo]=datetime.timezone.utc,
137+
default_timezone:Union[datetime.timezone, "BaseTzInfo"]=datetime.timezone.utc,
135138
encodings: Optional[List[str]]=None,
136139
exclude_obj_callback: Optional[Callable]=None,
137140
exclude_obj_callback_strict: Optional[Callable]=None,

deepdiff/helper.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
import string
99
import time
1010
import enum
11-
import pytz
12-
from typing import NamedTuple, Any, List, Optional, Dict, Union
11+
from typing import NamedTuple, Any, List, Optional, Dict, Union, TYPE_CHECKING
1312
from ast import literal_eval
1413
from decimal import Decimal, localcontext, InvalidOperation as InvalidDecimalOperation
1514
from itertools import repeat
1615
from orderly_set import StableSetEq as SetOrderedBase # median: 1.0867 s for cache test, 5.63s for all tests
1716
from threading import Timer
1817

18+
if TYPE_CHECKING:
19+
from pytz.tzinfo import BaseTzInfo
20+
1921

2022
class np_type:
2123
pass
@@ -614,7 +616,7 @@ def datetime_normalize(
614616
truncate_datetime:Union[str, None],
615617
obj:Union[datetime.datetime, datetime.time],
616618
default_timezone: Union[
617-
datetime.timezone, pytz.tzinfo.BaseTzInfo
619+
datetime.timezone, "BaseTzInfo"
618620
] = datetime.timezone.utc,
619621
) -> Any:
620622
if truncate_datetime:

docs/changelog.rst

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Changelog
55

66
DeepDiff Changelog
77

8+
- v8-4-1
9+
- Adding BaseOperatorPlus base class for custom operators
10+
- default_timezone can be passed now to set your default timezone to something other than UTC.
11+
- New summarization algorithm that produces valid json
12+
- Better type hint support
13+
- Breaking change in DeepHash where we raise Exception instead of logging if we can't hash a value.
14+
815
- v8-3-0
916
- Fixed some static typing issues
1017
- Added the summarize module for better repr of nested values

0 commit comments

Comments
 (0)