Repository: LeMyst/WikibaseIntegrator

Issue:
Rename Date -> Time here which makes more sense
https://github.com/LeMyst/WikibaseIntegrator/blob/d32ac9bb8ab877243d5d89824ed9d56ad2e49d98/wikibaseintegrator/wbi_enums.py#L58C7-L58C28

Hints from issue comments:

Solution patch:
diff --git a/README.md b/README.md
index f2451e6d..18792f4a 100644
--- a/README.md
+++ b/README.md
@@ -677,7 +677,7 @@ or modification of items.
 from wikibaseintegrator import WikibaseIntegrator, wbi_login
 from wikibaseintegrator.datatypes import ExternalID, Item, String, Time
 from wikibaseintegrator.wbi_config import config as wbi_config
-from wikibaseintegrator.wbi_enums import WikibaseDatePrecision
+from wikibaseintegrator.wbi_enums import WikibaseTimePrecision
 
 wbi_config['USER_AGENT'] = 'MyWikibaseBot/1.0 (https://www.wikidata.org/wiki/User:MyUsername)'
 
@@ -697,7 +697,7 @@ for entrez_id, ensembl in raw_data.items():
     references = [
         [
             Item(value='Q20641742', prop_nr='P248'),
-            Time(time='+2020-02-08T00:00:00Z', prop_nr='P813', precision=WikibaseDatePrecision.DAY),
+            Time(time='+2020-02-08T00:00:00Z', prop_nr='P813', precision=WikibaseTimePrecision.DAY),
             ExternalID(value='1017', prop_nr='P351')
         ]
     ]
@@ -744,7 +744,7 @@ The full example:
 ```python
 from wikibaseintegrator import WikibaseIntegrator, wbi_login
 from wikibaseintegrator.datatypes import ExternalID, Item, String, Time
-from wikibaseintegrator.wbi_enums import WikibaseDatePrecision
+from wikibaseintegrator.wbi_enums import WikibaseTimePrecision
 
 # login object
 login = wbi_login.OAuth2(consumer_token='<consumer_token>', consumer_secret='<consumer_secret>')
@@ -766,7 +766,7 @@ for entrez_id, ensembl in raw_data.items():
             Item(value='Q20641742', prop_nr='P248')
         ],
         [
-            Time(time='+2020-02-08T00:00:00Z', prop_nr='P813', precision=WikibaseDatePrecision.DAY),
+            Time(time='+2020-02-08T00:00:00Z', prop_nr='P813', precision=WikibaseTimePrecision.DAY),
             ExternalID(value='1017', prop_nr='P351')
         ]
     ]
diff --git a/docs/source/conf.py b/docs/source/conf.py
index a73731c3..e149777f 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -5,8 +5,8 @@
 #
 import os
 import sys
-from datetime import datetime
 from collections.abc import MutableMapping
+from datetime import datetime
 
 sys.path.insert(0, os.path.abspath('../..'))
 
diff --git a/wikibaseintegrator/datatypes/time.py b/wikibaseintegrator/datatypes/time.py
index 97dbb2f8..25576a01 100644
--- a/wikibaseintegrator/datatypes/time.py
+++ b/wikibaseintegrator/datatypes/time.py
@@ -5,7 +5,7 @@
 
 from wikibaseintegrator.datatypes.basedatatype import BaseDataType
 from wikibaseintegrator.wbi_config import config
-from wikibaseintegrator.wbi_enums import WikibaseDatePrecision
+from wikibaseintegrator.wbi_enums import WikibaseTimePrecision
 
 
 @total_ordering
@@ -21,7 +21,7 @@ class Time(BaseDataType):
         }}
     '''
 
-    def __init__(self, time: Optional[str] = None, before: int = 0, after: int = 0, precision: Union[int, WikibaseDatePrecision, None] = None, timezone: int = 0,
+    def __init__(self, time: Optional[str] = None, before: int = 0, after: int = 0, precision: Union[int, WikibaseTimePrecision, None] = None, timezone: int = 0,
                  calendarmodel: Optional[str] = None, wikibase_url: Optional[str] = None, **kwargs: Any):
         """
         Constructor, calls the superclass BaseDataType
@@ -41,7 +41,7 @@ def __init__(self, time: Optional[str] = None, before: int = 0, after: int = 0,
         super().__init__(**kwargs)
         self.set_value(time=time, before=before, after=after, precision=precision, timezone=timezone, calendarmodel=calendarmodel, wikibase_url=wikibase_url)
 
-    def set_value(self, time: Optional[str] = None, before: int = 0, after: int = 0, precision: Union[int, WikibaseDatePrecision, None] = None, timezone: int = 0,
+    def set_value(self, time: Optional[str] = None, before: int = 0, after: int = 0, precision: Union[int, WikibaseTimePrecision, None] = None, timezone: int = 0,
                   calendarmodel: Optional[str] = None, wikibase_url: Optional[str] = None):
         calendarmodel = calendarmodel or str(config['CALENDAR_MODEL_QID'])
         wikibase_url = wikibase_url or str(config['WIKIBASE_URL'])
@@ -66,23 +66,23 @@ def set_value(self, time: Optional[str] = None, before: int = 0, after: int = 0,
             pattern_year = re.compile(r'^[+-][0-9]{1,16}-(?:1[0-2]|0[0-9])-(?:3[01]|0[0-9]|[12][0-9])T00:00:00Z$')
             if not precision:
                 if pattern_day.match(time):
-                    precision = WikibaseDatePrecision.DAY
+                    precision = WikibaseTimePrecision.DAY
                 elif pattern_month.match(time):
-                    precision = WikibaseDatePrecision.MONTH
+                    precision = WikibaseTimePrecision.MONTH
                 elif pattern_year.match(time):
-                    precision = WikibaseDatePrecision.YEAR
+                    precision = WikibaseTimePrecision.YEAR
                 else:
                     raise ValueError(f"Time value ({time}) must be a string in the following format: '+%Y-%m-%dT00:00:00Z'.")
             else:
                 if isinstance(precision, int):
-                    precision = WikibaseDatePrecision(precision)
+                    precision = WikibaseTimePrecision(precision)
 
-                if precision not in WikibaseDatePrecision:
+                if precision not in WikibaseTimePrecision:
                     raise ValueError("Invalid value for time precision, see https://www.mediawiki.org/wiki/Wikibase/DataModel/JSON#time")
 
-                if precision == WikibaseDatePrecision.DAY:
+                if precision == WikibaseTimePrecision.DAY:
                     pattern = pattern_day
-                elif precision == WikibaseDatePrecision.MONTH:
+                elif precision == WikibaseTimePrecision.MONTH:
                     pattern = pattern_month
                 else:
                     pattern = pattern_year
diff --git a/wikibaseintegrator/wbi_enums.py b/wikibaseintegrator/wbi_enums.py
index 2d3a8547..b1ee1eec 100644
--- a/wikibaseintegrator/wbi_enums.py
+++ b/wikibaseintegrator/wbi_enums.py
@@ -58,7 +58,7 @@ class WikibaseSnakType(Enum):
     UNKNOWN_VALUE = "somevalue"
 
 
-class WikibaseDatePrecision(Enum):
+class WikibaseTimePrecision(Enum):
     # SECOND = 14  # UNSUPPORTED TO DATE (REL1_37)
     # MINUTE = 13  # UNSUPPORTED TO DATE (REL1_37)
     # HOUR = 12  # UNSUPPORTED TO DATE (REL1_37)


Test patch:
diff --git a/test/test_wbi_core.py b/test/test_wbi_core.py
index 18d22efd..afef470e 100644
--- a/test/test_wbi_core.py
+++ b/test/test_wbi_core.py
@@ -8,7 +8,7 @@
 from wikibaseintegrator.entities import ItemEntity
 from wikibaseintegrator.models import Descriptions
 from wikibaseintegrator.wbi_config import config as wbi_config
-from wikibaseintegrator.wbi_enums import ActionIfExists, WikibaseDatePrecision, WikibaseRank, WikibaseSnakType
+from wikibaseintegrator.wbi_enums import ActionIfExists, WikibaseRank, WikibaseSnakType, WikibaseTimePrecision
 from wikibaseintegrator.wbi_helpers import generate_entity_instances, search_entities
 
 wbi_config['USER_AGENT'] = 'WikibaseIntegrator-pytest/1.0 (test_wbi_core.py)'
@@ -225,13 +225,13 @@ def test_new_item_creation(self):
             Item(value=123, prop_nr='P4'),
             Item(value='Item:Q123', prop_nr='P4'),
             Item(value='http://www.wikidata.org/entity/Q123', prop_nr='P4'),
-            Time(time='-0458-01-01T00:00:00Z', before=1, after=2, precision=WikibaseDatePrecision.MILLION_YEARS, timezone=4, prop_nr='P5'),
-            Time(time='+458-01-01T00:00:00Z', before=1, after=2, precision=WikibaseDatePrecision.MILLION_YEARS, timezone=4, prop_nr='P5'),
+            Time(time='-0458-01-01T00:00:00Z', before=1, after=2, precision=WikibaseTimePrecision.MILLION_YEARS, timezone=4, prop_nr='P5'),
+            Time(time='+458-01-01T00:00:00Z', before=1, after=2, precision=WikibaseTimePrecision.MILLION_YEARS, timezone=4, prop_nr='P5'),
             Time(time='+2021-01-01T00:00:00Z', before=1, after=2, precision=3, timezone=4, prop_nr='P5'),
-            Time(time='now', before=1, after=2, precision=WikibaseDatePrecision.MONTH, timezone=4, prop_nr='P5'),
-            Time(time='+2021-01-00T00:00:00Z', before=1, after=2, precision=WikibaseDatePrecision.MONTH, timezone=4, prop_nr='P5'),
-            Time(time='+2021-00-00T00:00:00Z', before=1, after=2, precision=WikibaseDatePrecision.YEAR, timezone=4, prop_nr='P5'),
-            Time(time='+2021-00-00T00:00:00Z', before=1, after=2, precision=WikibaseDatePrecision.DECADE, timezone=4, prop_nr='P5'),
+            Time(time='now', before=1, after=2, precision=WikibaseTimePrecision.MONTH, timezone=4, prop_nr='P5'),
+            Time(time='+2021-01-00T00:00:00Z', before=1, after=2, precision=WikibaseTimePrecision.MONTH, timezone=4, prop_nr='P5'),
+            Time(time='+2021-00-00T00:00:00Z', before=1, after=2, precision=WikibaseTimePrecision.YEAR, timezone=4, prop_nr='P5'),
+            Time(time='+2021-00-00T00:00:00Z', before=1, after=2, precision=WikibaseTimePrecision.DECADE, timezone=4, prop_nr='P5'),
             URL(value="http://www.wikidata.org", prop_nr='P6'),
             URL(value="https://www.wikidata.org", prop_nr='P6'),
             URL(value="ftp://example.com", prop_nr='P6'),