Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
root = true

[*]
tab_width = 4
end_of_line = lf
max_line_length = 88
ij_visual_guides = 88
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,py,html}]
charset = utf-8

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab

[.flake8]
indent_style = space
indent_size = 2

[*.py]
indent_style = space
indent_size = 4
ij_python_from_import_parentheses_force_if_multiline = true
27 changes: 20 additions & 7 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ on:
- "v*.*.*"

jobs:
build:
run:
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Build and publish to PyPi
uses: JRubics/poetry-publish@v1.16
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
ignore_dev_requirements: "yes"
- name: Checkout
uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install Python 3.13
run: uv python install 3.13

- name: Build
run: uv build

- name: Publish
run: uv publish
61 changes: 26 additions & 35 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
name: Tests
name: Testing otlp_test

on: [ push, pull_request ]
on: push

jobs:
tests:
lint:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'

defaults:
run:
shell: bash

runs-on: ${{ matrix.os }}

include:
- name: Ruff format
cmd: ruff format --diff
- name: Ruff check
cmd: ruff check ymdantic tests
- name: Mypy
cmd: mypy ymdantic tests
- name: Pytest
cmd: pytest -vv tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
version: '0.9.17'
python-version: '3.13'
enable-cache: "auto"

- name: Install deps
run: uv sync --locked --all-groups

- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --with dev
- name: Lint code
run: |
poetry run ruff --output-format=github ymdantic
poetry run mypy ymdantic
poetry run black --check --diff ymdantic
- name: Run lint check
env:
YM_TOKEN: ${{ secrets.YM_TOKEN }}
run: uv run ${{ matrix.cmd }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# Tests
tests/
29 changes: 10 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.0
hooks:
- id: "check-ast"
- id: "trailing-whitespace"
Expand All @@ -11,28 +11,19 @@ repos:
- id: "detect-private-key"
- id: "check-toml"

- repo: https://github.com/asottile/add-trailing-comma
rev: v3.1.0
hooks:
- id: add-trailing-comma

- repo: https://github.com/psf/black
rev: 23.12.0
hooks:
- id: black
files: ymdantic/.*\.pyi?$|examples/.*\.pyi?$
args: ["--config", "pyproject.toml"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.9'
rev: 'v0.14.9'
hooks:
- id: ruff
- id: ruff-check
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
- repo: local
hooks:
- id: mypy
language_version: python3.10
additional_dependencies:
- pydantic
name: mypy
entry: uv run mypy
language: system
types: [python]
pass_filenames: false
args: ["ymdantic", "tests"]
13 changes: 11 additions & 2 deletions examples/chart.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import asyncio
import os

from ymdantic import YMClient

TOKEN = os.environ["TOKEN"]


async def get_chart() -> None:
"""Получаем чарт и выводим треки в консоль."""
client = YMClient(token=TOKEN)

async def get_chart(client: YMClient) -> None:
chart_block = await client.get_chart()
print(chart_block.title, end="\n\n")
print("Треки в чарте:")
for playlist_track in chart_block.chart.tracks:
print(f"{playlist_track.track.artists_names} - {playlist_track.track.title}")

await client.close()


if __name__ == "__main__":
asyncio.run(get_chart(client=YMClient(token="y0_123")))
asyncio.run(get_chart())
Loading