Skip to content

Commit d834c16

Browse files
authored
Merge pull request #100 from OpenXbox/fix/pydantic_v2
Compatibility improvements, meta changes
2 parents 398320c + 8fe0f8b commit d834c16

File tree

40 files changed

+603
-582
lines changed

40 files changed

+603
-582
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
11+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v4
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
2222
pip install -e .[dev]
23-
python setup.py develop
24-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
25-
- name: Lint with flake8
23+
- name: Lint with ruff
2624
run: |
27-
# stop the build if there are Python syntax errors or undefined names
28-
flake8 xbox --count --select=E9,F63,F7,F82 --show-source --statistics
29-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30-
flake8 xbox --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
25+
ruff check xbox
26+
ruff check tests
3127
- name: Test with pytest
3228
run: |
3329
pytest
@@ -36,20 +32,20 @@ jobs:
3632
runs-on: ubuntu-latest
3733
needs: build
3834
steps:
39-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v4
4036
- name: Set up Python
41-
uses: actions/setup-python@v2
37+
uses: actions/setup-python@v4
4238
with:
43-
python-version: '3.11'
39+
python-version: '3.12'
4440
- name: Install dependencies
4541
run: |
4642
python -m pip install --upgrade pip
47-
pip install setuptools wheel twine
43+
pip install setuptools wheel twine build
4844
- name: Build and publish
4945
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
5046
env:
5147
TWINE_USERNAME: __token__
5248
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
5349
run: |
54-
python setup.py sdist bdist_wheel
50+
python -m build
5551
twine upload dist/*

.pre-commit-config.yaml

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.2.0
4-
hooks:
5-
- id: pyupgrade
6-
args: [--py36-plus]
7-
- repo: https://github.com/psf/black
8-
rev: 22.10.0
9-
hooks:
10-
- id: black
11-
args:
12-
- --safe
13-
- --quiet
14-
files: ^((xbox|tests)/.+)?[^/]+\.py$
15-
- repo: https://gitlab.com/pycqa/flake8
16-
rev: 5.0.4
17-
hooks:
18-
- id: flake8
19-
additional_dependencies:
20-
# - flake8-docstrings==1.5.0
21-
- pydocstyle==5.1.1
22-
files: ^(xbox)/.+\.py$
23-
- repo: https://github.com/PyCQA/bandit
24-
rev: 1.7.4
25-
hooks:
26-
- id: bandit
27-
args:
28-
- --quiet
29-
- --format=custom
30-
- --configfile=bandit.yaml
31-
files: ^(xbox|tests)/.+\.py$
32-
- repo: https://github.com/PyCQA/isort
33-
rev: 5.10.1
34-
hooks:
35-
- id: isort
36-
- repo: https://github.com/pre-commit/pre-commit-hooks
37-
rev: v3.2.0
38-
hooks:
39-
- id: check-executables-have-shebangs
40-
stages: [manual]
41-
- id: check-json
42-
- repo: https://github.com/prettier/prettier
43-
rev: 2.0.4
44-
hooks:
45-
- id: prettier
46-
stages: [manual]
47-
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.1.6
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format
11+
- repo: https://github.com/asottile/pyupgrade
12+
rev: v3.15.0
13+
hooks:
14+
- id: pyupgrade
15+
args: [--py38-plus]
16+
- repo: https://github.com/psf/black
17+
rev: 23.11.0
18+
hooks:
19+
- id: black
20+
args:
21+
- --safe
22+
- --quiet
23+
files: ^((xbox|tests)/.+)?[^/]+\.py$
24+
- repo: https://github.com/PyCQA/bandit
25+
rev: 1.7.5
26+
hooks:
27+
- id: bandit
28+
args:
29+
- --configfile=pyproject.toml
30+
- --quiet
31+
- --format=custom
32+
files: ^(xbox|tests)/.+\.py$
33+
- repo: https://github.com/PyCQA/isort
34+
rev: 5.12.0
35+
hooks:
36+
- id: isort
37+
- repo: https://github.com/pre-commit/pre-commit-hooks
38+
rev: v4.5.0
39+
hooks:
40+
- id: check-executables-have-shebangs
41+
stages: [manual]
42+
- id: check-json

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ sphinx:
99

1010
build:
1111
# readdocs master now includes a rust toolchain
12-
os: "ubuntu-20.04"
12+
os: "ubuntu-22.04"
1313
tools:
14-
python: "3.9"
14+
python: "3.12"
1515

1616
python:
1717
install:

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 2.1.0 (2023-11-25)
4+
* ! Deprecate python 3.7 !
5+
* Deprecate flake8, use ruff for linting instead
6+
* Fixes for compatibility with v2 of json parsing library `pydantic`
7+
* Use python3.12 for CI and Docker
8+
* Migrate from setup.py to pyproject.toml
9+
* Remove requirements.txt
10+
* Use datetime functionality with higher compatibility
11+
312
## 2.0.11 (2021-04-30)
413

514
* Model validation fixes for optional properties (#41)

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cd xbox-webapi-python
6363
python -m venv venv
6464
source venv/bin/activate
6565
pip install -e .[dev]
66-
python setup.py develop
66+
pre-commit install
6767
```
6868

6969
4. Create a branch for local development::
@@ -98,6 +98,6 @@ Before you submit a pull request, check that it meets these guidelines:
9898
2. If the pull request adds functionality, the docs should be updated. Put
9999
your new functionality into a function with a docstring, and add the
100100
feature to the list in README.md.
101-
3. The pull request should work for Python 3.7+. Check
101+
3. The pull request should work for Python 3.8+. Check
102102
<https://github.com/OpenXbox/xbox-webapi-python/actions?query=workflow%3Abuild>
103103
and make sure that the tests pass for all supported Python versions.

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
#########################################
44
# Image WITH C compiler, building wheels for next stage
5-
FROM python:3.10-alpine as bigimage
5+
FROM python:3.12-alpine as bigimage
66

77
ENV LANG C.UTF-8
88

99
# Copy project files
1010
COPY . /src/xbox-webapi
1111

1212
# install the C compiler
13-
RUN apk add --no-cache jq gcc musl-dev libffi-dev openssl-dev
13+
RUN apk add --no-cache jq gcc musl-dev libffi-dev openssl-dev cargo
1414

1515
# instead of installing, create a wheel
1616
RUN pip wheel --wheel-dir=/root/wheels /src/xbox-webapi
1717

1818
#########################################
1919
# Image WITHOUT C compiler, installing the component from wheel
20-
FROM python:3.10-alpine as smallimage
20+
FROM python:3.12-alpine as smallimage
2121

2222
RUN apk add --no-cache openssl
2323

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,16 @@ clean-pyc: ## remove Python file artifacts
4545
find . -name '__pycache__' -exec rm -fr {} +
4646

4747
clean-test: ## remove test and coverage artifacts
48-
rm -fr .tox/
4948
rm -f .coverage
5049
rm -fr htmlcov/
5150

52-
lint: ## check style with flake8
53-
flake8 xbox tests
51+
lint: ## check style with ruff
52+
ruff check --fix xbox
53+
ruff check --fix tests
5454

5555
test: ## run tests quickly with the default Python
5656
py.test
5757

58-
test-all: ## run tests on every Python version with tox
59-
tox
60-
6158
coverage: ## check code coverage quickly with the default Python
6259
coverage run --source xbox -m pytest
6360
coverage report -m
@@ -79,11 +76,9 @@ release: clean ## package and upload a release
7976
twine upload dist/*
8077

8178
dist: clean ## builds source and wheel package
82-
python setup.py sdist
83-
python setup.py bdist_wheel
79+
python -m build
8480
ls -l dist
8581

8682
install: clean ## install the package to the active Python's site-packages
87-
pip install -r requirements.txt
8883
pre-commit install
8984
pip install -e .

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Authentication is supported via OAuth2.
1919

2020
## Dependencies
2121

22-
- Python >= 3.7
22+
- Python >= 3.8
2323

2424
## How to use
2525

@@ -100,12 +100,17 @@ async def async_main():
100100
with open(tokens_file) as f:
101101
tokens = f.read()
102102
# Assign gathered tokens
103-
auth_mgr.oauth = OAuth2TokenResponse.parse_raw(tokens)
103+
auth_mgr.oauth = OAuth2TokenResponse.model_validate_json(tokens)
104104
except FileNotFoundError as e:
105105
print(
106106
f"File {tokens_file} isn`t found or it doesn`t contain tokens! err={e}"
107107
)
108-
sys.exit(-1)
108+
print("Authorizing via OAUTH")
109+
url = auth_mgr.generate_authorization_url()
110+
print(f"Auth via URL: {url}")
111+
authorization_code = input("Enter authorization code> ")
112+
tokens = await auth_mgr.request_oauth_token(authorization_code)
113+
auth_mgr.oauth = tokens
109114

110115
"""
111116
Refresh tokens, just in case

bandit.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# The short X.Y version
3030
version = '1.0'
3131
# The full version, including alpha/beta/rc tags
32-
release = '2.0.11'
32+
release = '2.1.0'
3333

3434

3535
# -- General configuration ---------------------------------------------------

0 commit comments

Comments
 (0)