Skip to content

Commit

Permalink
meta: cleanup, bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Nov 25, 2023
1 parent 364ac01 commit b84f6ba
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 72 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 xbox --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 xbox --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check xbox
ruff check tests
- name: Test with pytest
run: |
pytest
Expand All @@ -35,20 +32,20 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build
- name: Build and publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,38 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((xbox|tests)/.+)?[^/]+\.py$
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args:
- --configfile=pyproject.toml
- --quiet
- --format=custom
files: ^(xbox|tests)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-executables-have-shebangs
stages: [manual]
- id: check-json
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ sphinx:

build:
# readdocs master now includes a rust toolchain
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "3.9"
python: "3.12"

python:
install:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

ENV LANG C.UTF-8

Expand All @@ -17,7 +17,7 @@ RUN pip wheel --wheel-dir=/root/wheels /src/xbox-webapi

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

RUN apk add --no-cache openssl

Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,16 @@ clean-pyc: ## remove Python file artifacts
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/

lint: ## check style with flake8
flake8 xbox tests
ruff check --fix xbox
ruff check --fix tests

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

test-all: ## run tests on every Python version with tox
tox

coverage: ## check code coverage quickly with the default Python
coverage run --source xbox -m pytest
coverage report -m
Expand All @@ -84,6 +81,5 @@ dist: clean ## builds source and wheel package
ls -l dist

install: clean ## install the package to the active Python's site-packages
pip install -r requirements.txt
pre-commit install
pip install -e .
17 changes: 0 additions & 17 deletions bandit.yaml

This file was deleted.

94 changes: 86 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [
"ecdsa",
"httpx",
"ms_cv",
"pydantic",
"pydantic==2.*",
]
requires-python = ">=3.8"
readme = "README.md"
Expand All @@ -21,12 +21,11 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Libraries :: Python Modules",
]

Expand All @@ -35,19 +34,28 @@ Homepage = "https://github.com/OpenXbox/xbox-webapi-python"

[project.optional-dependencies]
dev = [
# Tagging releases
"bump2version",
# Testing
"coverage",
"flake8",
"pip",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-runner",
"respx",
"tox",
# Packaging
"twine",
"watchdog",
"wheel",
# Pre-commit / Linting
"ruff==0.1.6",
"pre-commit==3.5.0",
"pyupgrade==3.15.0",
"black==23.11.0",
# "flake8-docstrings==1.5.0",
"pydocstyle==6.1.1",
"bandit==1.7.5",
"isort==5.12.0",
]
docs = [
"Sphinx",
Expand All @@ -62,13 +70,83 @@ xbox-friends = "xbox.webapi.scripts.friends:main"
xbox-searchlive = "xbox.webapi.scripts.search:main"
xbox-xal = "xbox.webapi.scripts.xal:main"

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

# Assume Python 3.8
target-version = "py38"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F"]
ignore = []

fixable = ["ALL"]
unfixable = []
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.bandit]
exclude_dirs = ["tests"]
tests = [
"B108",
"B306",
"B307",
"B313",
"B314",
"B315",
"B316",
"B317",
"B318",
"B319",
"B320",
"B602",
"B604"
]

[tool.black]
target-version = ["py37", "py38", "py39", "py310", "py311"]
exclude = 'generated'

[tool.setuptools.packages.find]
where = ["."]
include = ["xbox.webapi"]
include = ["xbox.webapi.*"]

[build-system]
requires = ["setuptools>=61", "wheel"]
Expand Down
23 changes: 0 additions & 23 deletions requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions tests/test_xal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import uuid

from httpx import AsyncClient, Response
import pytest

Expand Down

0 comments on commit b84f6ba

Please sign in to comment.