Skip to content

Commit a4f585f

Browse files
committed
Merge branch '1.4.x' into dev
2 parents 517c9c9 + 3848d51 commit a4f585f

25 files changed

+128
-74
lines changed

.github/workflows/lint-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
python-version: [3.7, 3.8, 3.9, '3.10']
20+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
2121

2222
steps:
2323
- uses: actions/checkout@v3

.readthedocs.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the version of Python and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.9"
12+
13+
# Build documentation in the docs/ directory with Sphinx
14+
sphinx:
15+
configuration: docs/conf.py
16+
17+
# We recommend specifying your dependencies to enable reproducible builds:
18+
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
19+
python:
20+
install:
21+
- requirements: docs/requirements.txt

CHANGELOG.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ The format is based on
77
`Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`__, and this project
88
adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`__.
99

10+
Version 1.4.3 (2024-02-21)
11+
--------------------------
12+
13+
Changed
14+
*******
15+
16+
- Every `datetime.date <https://docs.python.org/library/datetime.html#datetime.date>`__ is now timezone aware, using the CodinGame
17+
timezone (UTC).
18+
- `ClashOfCode.creation_time <https://codingame.readthedocs.io/en/latest/api.html#codingame.ClashOfCode.creation_time>`__ can be ``None`` because of an API change
19+
by CodinGame.
20+
21+
Fixed
22+
*****
23+
24+
- `KeyError <https://docs.python.org/library/exceptions.html#KeyError>`__ was raised when using `Client.get_clash_of_code <https://codingame.readthedocs.io/en/latest/api.html#codingame.Client.get_clash_of_code>`__ because
25+
of an API change by CodinGame.
26+
27+
Removed
28+
*******
29+
30+
- Removed support for python 3.7 as it has reached its end of life. For more
31+
information, see `PEP 537 <https://peps.python.org/pep-0537/#lifespan>`__.
32+
1033
Version 1.4.2 (2023-04-14)
1134
--------------------------
1235

@@ -66,7 +89,7 @@ Changed
6689
Removed
6790
*******
6891

69-
- Removed `Notification._raw`.
92+
- Removed ``Notification._raw``.
7093

7194
Version 1.2.4 (2022-06-17)
7295
--------------------------

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Pythonic wrapper for the undocumented `CodinGame <https://www.codingame.com/>`_
2929
Installation
3030
------------
3131

32-
**Python 3.7 or higher is required.**
32+
**Python 3.8 or higher is required.**
3333

3434
Install ``codingame`` with pip:
3535

codingame/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"VersionInfo", major=int, minor=int, micro=int, releaselevel=str, serial=int
1212
)
1313

14-
version_info = VersionInfo(major=1, minor=4, micro=2, releaselevel="", serial=0)
14+
version_info = VersionInfo(major=1, minor=4, micro=3, releaselevel="", serial=0)
1515

1616
__title__ = "codingame"
1717
__author__ = "takos22"
18-
__version__ = "1.4.2"
18+
__version__ = "1.4.3"
1919

2020
from .clash_of_code import ClashOfCode, Player
2121
from .client import Client

codingame/clash_of_code.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ class ClashOfCode(BaseObject):
5858
mode: Optional :class:`str`
5959
The mode of the Clash of Code.
6060
61-
creation_time: :class:`~datetime.datetime`
61+
creation_time: Optional :class:`~datetime.datetime`
6262
Creation time of the Clash of Code.
63+
Doesn't always exist.
6364
6465
start_time: :class:`~datetime.datetime`
6566
Start time of the Clash of Code. If the Clash of Code hasn't started
@@ -88,7 +89,7 @@ class ClashOfCode(BaseObject):
8889
started: bool
8990
finished: bool
9091
mode: Optional[Mode]
91-
creation_time: datetime
92+
creation_time: Optional[datetime]
9293
start_time: datetime
9394
end_time: Optional[datetime]
9495
time_before_start: timedelta
@@ -125,7 +126,7 @@ def _set_data(self, data: ClashOfCodeDict):
125126
f"https://www.codingame.com/clashofcode/clash/{self.public_handle}",
126127
)
127128

128-
self._setattr("public", data["publicClash"])
129+
self._setattr("public", data.get("type", "PUBLIC") == "PUBLIC")
129130
self._setattr("min_players", data["nbPlayersMin"])
130131
self._setattr("max_players", data["nbPlayersMax"])
131132
self._setattr("modes", data.get("modes"))
@@ -135,8 +136,8 @@ def _set_data(self, data: ClashOfCodeDict):
135136
self._setattr("finished", data["finished"])
136137
self._setattr("mode", data.get("mode"))
137138

138-
self._setattr("creation_time", to_datetime(data["creationTime"]))
139-
self._setattr("start_time", to_datetime(data.get("startTime")))
139+
self._setattr("creation_time", to_datetime(data.get("creationTime")))
140+
self._setattr("start_time", to_datetime(data.get("startTimestamp")))
140141
self._setattr("end_time", to_datetime(data.get("endTime")))
141142

142143
self._setattr(

codingame/types/clash_of_code.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
Typings for the `ClashOfCode/` endpoints of the CodinGame API.
55
"""
66

7-
from typing import List, Optional
8-
9-
try:
10-
from typing import Literal, TypedDict
11-
except ImportError:
12-
from typing_extensions import Literal, TypedDict
7+
from typing import List, Literal, Optional, TypedDict
138

149
from .codingamer import PartialCodinGamer
1510

codingame/types/codingamer.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
Typings for the `CodinGamer/` endpoints of the CodinGame API.
55
"""
66

7-
from typing import Dict, List, Optional
8-
9-
try:
10-
from typing import Literal, TypedDict
11-
except ImportError:
12-
from typing_extensions import Literal, TypedDict
7+
from typing import Dict, List, Literal, Optional, TypedDict
138

149
__all__ = (
1510
"PartialCodinGamer",

codingame/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
import typing
3-
from datetime import datetime
3+
from datetime import datetime, timezone
44

55
from .exceptions import LoginRequired
66

@@ -103,8 +103,8 @@ def validate_leaderboard_group(group: str, logged_in: bool) -> str:
103103

104104
def to_datetime(data: typing.Optional[typing.Union[int, str]]) -> datetime:
105105
if isinstance(data, int):
106-
return datetime.utcfromtimestamp(data / 1000.0)
107-
elif isinstance(data, str):
106+
return datetime.fromtimestamp(data / 1000.0, timezone.utc)
107+
elif isinstance(data, str): # pragma: no cover
108108
try:
109109
return datetime.strptime(data, DT_FORMAT_1)
110110
except ValueError:

dev-requirements.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
autoflake~=1.4
1+
autoflake~=2.3
22
black~=22.6
3-
doc8~=0.9
4-
flake8~=3.9
5-
importlib-metadata~=4.13
6-
isort~=5.8
7-
pytest~=6.2
3+
doc8~=1.1
4+
flake8~=7.0
5+
isort~=5.13
6+
pytest~=7.4
87
pytest-asyncio~=0.16.0
9-
pytest-cov~=2.12
8+
pytest-cov~=4.1
109
pytest-mock~=3.6
11-
python-dotenv~=0.17.1
12-
requests
13-
twine
10+
python-dotenv~=1.0
11+
setuptools~=69.1
12+
twine~=5.0

0 commit comments

Comments
 (0)