Skip to content

Commit bed6a33

Browse files
2.0.12 (#417)
Pull request ============ Description ----------- Fixed error with urllib3, added Python 3.12 to testing and modules updates How Has This Been Tested ------------------------ GitHub Actions with pytest Types of changes ---------------- - [x] Bug fix (#416) - [x] Added Python 3.12 support, removed Python 3.7 - [x] Dependencies updated - [x] Vulnerabilities fixes --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 2a5f8e8 commit bed6a33

16 files changed

+105
-67
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
language: ["python"]
2323
steps:
2424
- name: Checkout repository
25-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
2626
- name: Initialize CodeQL
2727
uses: github/codeql-action/init@v2
2828
with:

.github/workflows/codestyle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
name: Check code style
1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919
- uses: RojerGS/python-black-check@master
2020
with:
2121
line-length: "88"

.github/workflows/publish.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,35 @@ jobs:
1616
test:
1717
environment:
1818
name: Testing
19-
runs-on: ubuntu-latest
2019
strategy:
20+
fail-fast: false
2121
matrix:
22-
python-version: [3.7, 3.8, 3.9, "3.10"]
22+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
23+
os: [ubuntu-latest, windows-latest, macos-latest]
24+
include:
25+
- os: ubuntu-latest
26+
path: ~/.cache/pip
27+
- os: macos-latest
28+
path: ~/Library/Caches/pip
29+
- os: windows-latest
30+
path: ~\AppData\Local\pip\Cache
31+
runs-on: ${{ matrix.os }}
2332
steps:
24-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v4
2534
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v5
2736
with:
2837
python-version: ${{ matrix.python-version }}
2938
- name: Cache pip
30-
uses: actions/cache@v3
39+
uses: actions/cache@v4
3140
with:
32-
path: ~/.cache/pip
33-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
41+
path: ${{ matrix.path }}
42+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ matrix.python-version }}
43+
- name: Update pip, wheel and setuptools
44+
run: |
45+
python -m pip install --upgrade pip wheel setuptools
3446
- name: Install dependencies
3547
run: |
36-
python -m pip install --upgrade pip wheel
3748
pip install -r requirements.txt
3849
pip install .
3950
- name: Test with pytest
@@ -45,16 +56,16 @@ jobs:
4556
name: Build and publish Python 🐍 distributions 📦 to PyPI
4657
runs-on: ubuntu-latest
4758
steps:
48-
- uses: actions/checkout@v3
49-
- name: Set up Python 3.9
50-
uses: actions/setup-python@v4
59+
- uses: actions/checkout@v4
60+
- name: Set up Python 3.12
61+
uses: actions/setup-python@v5
5162
with:
52-
python-version: 3.9
63+
python-version: "3.12"
5364
- name: Cache pip
54-
uses: actions/cache@v3
65+
uses: actions/cache@v4
5566
with:
5667
path: ~/.cache/pip
57-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
68+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ matrix.python-version }}
5869
restore-keys: |
5970
${{ runner.os }}-pip-
6071
- name: Install requirements
@@ -65,7 +76,7 @@ jobs:
6576
run: |
6677
python setup.py sdist
6778
- name: Publish distribution 📦 to PyPI
68-
uses: pypa/[email protected].1
79+
uses: pypa/[email protected].2
6980
with:
7081
password: ${{ secrets.pypi_password }}
7182
release:
@@ -75,7 +86,7 @@ jobs:
7586
runs-on: ubuntu-latest
7687
steps:
7788
- name: Checkout code
78-
uses: actions/checkout@v3
89+
uses: actions/checkout@v4
7990
- name: Create Release
8091
id: create_release
8192
uses: actions/[email protected]

.github/workflows/wiki.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v3
15-
- name: Install Python 3.8
16-
uses: actions/setup-python@v4
14+
- uses: actions/checkout@v4
15+
- name: Install Python 3.12
16+
uses: actions/setup-python@v5
1717
with:
18-
python-version: 3.8
18+
python-version: 3.12
1919
- name: Install dependencies
2020
run: >-
2121
pip install pydoc-markdown mkdocs

codeforces_api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
You should have received a copy of the GNU General Public License
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
"""
17+
1718
__all__ = ["CodeforcesApi", "CodeforcesApiRequestMaker", "CodeforcesParser"]
1819
from codeforces_api.api_request_maker import CodeforcesApiRequestMaker
1920
from codeforces_api.api_requests import CodeforcesApi

codeforces_api/api_request_maker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
You should have received a copy of the GNU General Public License
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
"""
17+
1718
import collections
1819
import hashlib
1920
import json
2021
import random
2122
import time
2223

23-
import requests
24+
import urllib
2425

2526

2627
class CodeforcesApiRequestMaker:
@@ -68,7 +69,7 @@ def generate_request(self, method_name, **fields):
6869
fields["time"] = str(int(current_time))
6970
api_signature = str(self._rand) + "/" + method_name + "?"
7071
fields = collections.OrderedDict(sorted(fields.items()))
71-
api_signature += requests.urllib3.request.urlencode(fields, safe=";")
72+
api_signature += urllib.parse.urlencode(fields, safe=";")
7273
api_signature += "#" + str(self._secret)
7374
hashed_signature = hashlib.sha512(api_signature.encode("utf-8"))
7475
fields["apiSig"] = str(self._rand) + str(hashed_signature.hexdigest())

codeforces_api/api_requests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
You should have received a copy of the GNU General Public License
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
"""
17+
1718
import requests
1819

1920
from codeforces_api.api_request_maker import CodeforcesApiRequestMaker

codeforces_api/parse_methods.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
You should have received a copy of the GNU General Public License
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
"""
17+
1718
import requests
1819
from lxml import html
1920

@@ -43,7 +44,12 @@ def get_solution(self, contest_id, submit_id):
4344
"https://codeforces.com/contest/"
4445
+ str(contest_id)
4546
+ "/submission/"
46-
+ str(submit_id)
47+
+ str(submit_id),
48+
cookies={
49+
"RCPC": "333e1cab3b9ab19c225e45305669bef8",
50+
"expires": "Thu, 31-Dec-37 23:55:55 GMT",
51+
"path": "/",
52+
},
4753
)
4854
if int(solutionPage.status_code) != 200:
4955
raise Exception("Returned not OK code " + str(solutionPage))

codeforces_api/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
Source of inspiration: https://github.com/eternnoir/pyTelegramBotAPI/blob/master/telebot/types.py
1717
"""
18+
1819
import json
1920

2021

codeforces_api/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.11"
1+
__version__ = "2.0.12"

requirements.txt

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
11
appdirs==1.4.4
2-
astroid==2.12.9
2+
astroid==2.12.13
33
atomicwrites==1.4.1
44
attrs==22.1.0
5-
black==22.8.0
5+
black==24.4.2
66
bleach==5.0.1
7-
certifi==2022.6.15
7+
certifi==2024.6.2
88
chardet==5.0.0
99
charset-normalizer==2.1.1
1010
click==8.1.3
11-
colorama==0.4.5
11+
colorama==0.4.6
1212
commonmark==0.9.1
13-
dill==0.3.5.1
13+
dill==0.3.6
1414
docutils==0.19
15-
idna==2.10
16-
importlib-metadata==4.12.0
15+
exceptiongroup==1.0.4
16+
idna==3.4
17+
importlib-metadata==5.0.0
1718
iniconfig==1.1.1
1819
isort==5.10.1
19-
keyring==23.9.1
20-
lazy-object-proxy==1.7.1
21-
lxml==4.9.1
20+
jaraco.classes==3.4.0
21+
keyring==23.11.0
22+
lazy-object-proxy==1.9.0
23+
lxml==5.2.2
2224
mccabe==0.6.1
25+
more-itertools==8.14.0
2326
mypy-extensions==0.4.3
24-
packaging==21.3
25-
pathspec==0.10.1
27+
packaging==24.1
28+
pathspec==0.10.2
2629
pkginfo==1.8.3
27-
platformdirs==2.5.2
30+
platformdirs==2.5.4
2831
pluggy==1.0.0
29-
py==1.11.0
30-
Pygments==2.13.0
31-
pylint==2.15.2
32+
Pygments==2.15.0
33+
pylint==2.15.7
3234
pyparsing==3.0.9
33-
pytest==7.1.3
35+
pytest==7.2.0
3436
pywin32-ctypes==0.2.0
35-
readme-renderer==37.1
36-
regex==2022.8.17
37-
requests==2.28.1
38-
requests-toolbelt==0.9.1
37+
readme-renderer==37.3
38+
regex==2022.10.31
39+
requests==2.32.3
40+
requests-toolbelt==0.10.1
3941
rfc3986==2.0.0
40-
rich==12.5.1
42+
rich==12.6.0
4143
six==1.16.0
4244
toml==0.10.2
4345
tomli==2.0.1
44-
tomlkit==0.11.4
45-
tqdm==4.64.1
46+
tomlkit==0.11.6
47+
tqdm==4.66.4
4648
twine==4.0.1
47-
typed-ast==1.5.4
48-
typing_extensions==4.3.0
49-
urllib3==1.26.12
49+
typed_ast==1.5.4
50+
typing_extensions==4.4.0
51+
urllib3==2.2.2
5052
webencodings==0.5.1
5153
wrapt==1.14.1
52-
zipp==3.8.1
54+
zipp==3.11.0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Install script for CodeforcesApiPy module
33
"""
4+
45
import re
56

67
from setuptools import setup
@@ -29,5 +30,5 @@
2930
],
3031
keywords="codeforces api python",
3132
install_requires=["requests", "lxml"],
32-
python_requires=">=3.7",
33+
python_requires=">=3.8",
3334
)

tests/conftest.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
11
"""
22
Config file for tests
33
"""
4+
45
import pytest
56

67

78
def pytest_addoption(parser):
89
parser.addoption(
910
"--api_key",
1011
action="store",
11-
default="api_key",
12+
default="",
1213
help="API key for tests",
1314
)
1415
parser.addoption(
1516
"--api_secret",
1617
action="store",
17-
default="api_secret",
18+
default="",
1819
help="API secret for tests",
1920
)
2021

2122

2223
@pytest.fixture
2324
def api_key(request):
24-
return request.config.getoption("--api_key")
25+
try:
26+
import conf
27+
28+
return conf.api_key
29+
except ModuleNotFoundError:
30+
return request.config.getoption("--api_key")
2531

2632

2733
@pytest.fixture
2834
def api_secret(request):
29-
return request.config.getoption("--api_secret")
35+
try:
36+
import conf
37+
38+
return conf.api_secret
39+
except ModuleNotFoundError:
40+
return request.config.getoption("--api_secret")
3041

3142

3243
@pytest.fixture

tests/test_api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Testing requests to api.
33
"""
4+
45
from codeforces_api.types import BlogEntry, Comment, Party, Problem
56
from codeforces_api import CodeforcesApi
67

@@ -75,7 +76,7 @@ def test_contest_list():
7576
contests = api.contest_list()
7677
for contest in contests:
7778
if contest.id == 1496:
78-
assert contest.name == "Codeforces Round #706 (Div. 2)"
79+
assert contest.name == "Codeforces Round 706 (Div. 2)"
7980
assert contest.contest_type == "CF"
8081
assert contest.phase == "FINISHED"
8182
assert not contest.frozen
@@ -99,7 +100,7 @@ def test_contest_rating_changes():
99100
for change in changes:
100101
if change.handle == "VadVergasov":
101102
assert change.contest_id == 1313
102-
assert change.contest_name == "Codeforces Round #622 (Div. 2)"
103+
assert change.contest_name == "Codeforces Round 622 (Div. 2)"
103104
assert change.rank == 2303
104105
assert change.rating_update_time_seconds == 1582455900
105106
assert change.old_rating == 1330
@@ -111,7 +112,7 @@ def test_contest_standings():
111112
api = CodeforcesApi()
112113
standings = api.contest_standings(1313, handles=["VadVergasov"])
113114
assert standings["contest"].id == 1313
114-
assert standings["contest"].name == "Codeforces Round #622 (Div. 2)"
115+
assert standings["contest"].name == "Codeforces Round 622 (Div. 2)"
115116
assert standings["contest"].contest_type == "CF"
116117
assert standings["contest"].phase == "FINISHED"
117118
assert not standings["contest"].frozen
@@ -187,7 +188,7 @@ def test_contest_status():
187188
assert row.author.contest_id == 1313
188189
assert row.author.room == 10
189190
assert row.author.start_time_seconds == 1582448700
190-
assert row.programming_language == "GNU C++17"
191+
assert row.programming_language == "C++17 (GCC 7-32)"
191192
assert row.testset == "TESTS"
192193
assert row.passed_test_count == 5
193194
assert row.time_consumed_millis == 171

0 commit comments

Comments
 (0)