Skip to content

Commit 024aa28

Browse files
committed
feat: initial implementation
1 parent 4f07dd2 commit 024aa28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4734
-0
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v4
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: uv sync --all-extras
29+
30+
- name: Run ruff check
31+
run: uv run ruff check src/
32+
33+
- name: Run ruff format check
34+
run: uv run ruff format --check src/
35+
36+
- name: Run mypy
37+
run: uv run mypy src/
38+
39+
- name: Run tests
40+
run: uv run pytest -v

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
25+
with:
26+
version: "latest"
27+
28+
- name: Set up Python
29+
run: uv python install 3.11
30+
31+
- name: Install dependencies
32+
run: uv sync --all-extras
33+
34+
- name: Build documentation
35+
run: uv run mkdocs build
36+
37+
- name: Upload artifact
38+
uses: actions/upload-pages-artifact@v3
39+
with:
40+
path: site/
41+
42+
deploy:
43+
environment:
44+
name: github-pages
45+
url: ${{ steps.deployment.outputs.page_url }}
46+
runs-on: ubuntu-latest
47+
needs: build
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
target:
9+
description: "Deployment target"
10+
required: true
11+
default: "testpypi"
12+
type: choice
13+
options:
14+
- testpypi
15+
- pypi
16+
17+
permissions:
18+
contents: read
19+
id-token: write
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v4
29+
with:
30+
version: "latest"
31+
32+
- name: Set up Python
33+
run: uv python install 3.11
34+
35+
- name: Build package
36+
run: uv build
37+
38+
- name: Upload dist artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: dist
42+
path: dist/
43+
44+
publish-testpypi:
45+
runs-on: ubuntu-latest
46+
needs: build
47+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
48+
environment:
49+
name: testpypi
50+
url: https://test.pypi.org/p/mcsrranked
51+
steps:
52+
- name: Download dist artifacts
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: dist
56+
path: dist/
57+
58+
- name: Publish to TestPyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
repository-url: https://test.pypi.org/legacy/
62+
63+
publish-pypi:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
67+
environment:
68+
name: pypi
69+
url: https://pypi.org/p/mcsrranked
70+
steps:
71+
- name: Download dist artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
name: dist
75+
path: dist/
76+
77+
- name: Publish to PyPI
78+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.nox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
*.py,cover
48+
.hypothesis/
49+
.pytest_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Environments
56+
.env
57+
.venv
58+
env/
59+
venv/
60+
ENV/
61+
env.bak/
62+
venv.bak/
63+
64+
# IDE
65+
.idea/
66+
.vscode/
67+
*.swp
68+
*.swo
69+
70+
# mypy
71+
.mypy_cache/
72+
.dmypy.json
73+
dmypy.json
74+
75+
# ruff
76+
.ruff_cache/
77+
78+
# uv
79+
uv.lock
80+
81+
# mkdocs
82+
site/

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.8.6
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v5.0.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-yaml
15+
- id: check-added-large-files
16+
- id: check-toml

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# mcsrranked
2+
3+
mcsrranked is a Python SDK for the [MCSR Ranked API](https://mcsrranked.com/).
4+
5+
[![PyPI version](https://badge.fury.io/py/mcsrranked.svg)](https://badge.fury.io/py/mcsrranked)
6+
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8+
9+
## Installation
10+
11+
```bash
12+
# Using uv
13+
uv add mcsrranked
14+
15+
# Using pip
16+
pip install mcsrranked
17+
```
18+
19+
## Examples
20+
21+
```python
22+
import mcsrranked
23+
24+
# Get a player's profile
25+
user = mcsrranked.users.get("Feinberg")
26+
print(f"{user.nickname}: {user.elo_rate} elo")
27+
28+
# Get the leaderboard
29+
leaderboard = mcsrranked.leaderboards.elo()
30+
for player in leaderboard.users[:5]:
31+
print(f"#{player.elo_rank} {player.nickname}")
32+
```
33+
34+
See more [examples](https://github.com/camodotgg/mcsrranked-python/tree/main/examples).
35+
36+
## Documentation
37+
38+
For full documentation, visit **[camodotgg.github.io/mcsrranked-python](https://camodotgg.github.io/mcsrranked-python)**.
39+
40+
- [Getting Started](https://camodotgg.github.io/mcsrranked-python/getting-started/quickstart/)
41+
- [API Reference](https://camodotgg.github.io/mcsrranked-python/api/client/)
42+
- [Examples](https://camodotgg.github.io/mcsrranked-python/examples/)
43+
44+
## Contributing
45+
46+
```bash
47+
git clone https://github.com/camodotgg/mcsrranked-python
48+
cd mcsrranked-python
49+
uv sync --all-extras
50+
uv run pre-commit install
51+
```
52+
53+
Run checks:
54+
55+
```bash
56+
uv run ruff check src/
57+
uv run mypy src/
58+
uv run pytest
59+
```

0 commit comments

Comments
 (0)