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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Force LF for tracked Python source - Windows checkouts must not silently gain CRLF (git's
# own core.autocrlf conversion) on files migration writers/tests compare byte-for-byte, and
# generated migrations under */migrations/ are always written with explicit LF (see
# hare/migrations/writer.py's MigrationWriter.write()) regardless of the platform that ran
# makemigrations.
*.py text eol=lf

# Shell scripts run inside Linux containers (tests/docker) - a CRLF line ending breaks their shebang.
*.sh text eol=lf
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Every pull request requests a review from the maintainer.
* @VladislavYar
79 changes: 79 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Bug report / Сообщение об ошибке
description: Something in hare-orm behaves incorrectly. / Что-то в hare-orm работает неправильно.
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report this. Security vulnerabilities should go through
[SECURITY.md](https://github.com/hare-orm/hare-orm/security/policy) instead of a
public issue.

Спасибо, что нашли время сообщить. Об уязвимостях сообщайте по правилам
[SECURITY](https://github.com/hare-orm/hare-orm/security/policy), а не публичным issue.

- type: checkboxes
id: checks
attributes:
label: Before reporting / Перед сообщением
options:
- label: I searched the existing issues and this hasn't been reported yet. / Я поискал среди существующих issues, об этом ещё не сообщали.
required: true
- label: It happens on the latest release (or on `dev`). / Это происходит на последнем выпуске (или на `dev`).
required: true

- type: textarea
id: description
attributes:
label: What happened? / Что произошло?
description: What did you expect, and what actually happened instead? / Чего вы ожидали и что произошло на самом деле?
validations:
required: true

- type: textarea
id: repro
attributes:
label: Minimal reproduction / Минимальное воспроизведение
description: >
A minimal model + code snippet that reproduces it. A runnable script (e.g. against
`sqlite+aiosqlite://:memory:`) gets a faster fix than a description alone.
Минимальная модель и фрагмент кода, которые воспроизводят ошибку. Запускаемый скрипт
(например, на `sqlite+aiosqlite://:memory:`) исправят быстрее, чем одно описание.
render: python
validations:
required: true

- type: input
id: version
attributes:
label: hare-orm version / Версия hare-orm
placeholder: "e.g. 0.9.0, or a commit hash if installed from git / например 0.9.0 или хеш коммита при установке из git"
validations:
required: true

- type: dropdown
id: dialect
attributes:
label: Dialect and driver / Диалект и драйвер
multiple: true
options:
- SQLite
- PostgreSQL (rust_pg, postgresql://)
- PostgreSQL (asyncpg, postgresql+asyncpg://)
- A third-party dialect / Сторонний диалект
validations:
required: true

- type: input
id: python-version
attributes:
label: Python version / Версия Python
placeholder: "e.g. 3.14.1 / например 3.14.1"
validations:
required: true

- type: textarea
id: traceback
attributes:
label: Traceback / error output / Трассировка или вывод ошибки
render: text
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Security vulnerability / Уязвимость
url: https://github.com/hare-orm/hare-orm/security/advisories/new
about: Please report vulnerabilities privately - see SECURITY.md. / Сообщайте об уязвимостях закрыто - см. SECURITY.ru.md.
- name: Documentation / Документация
url: https://hare-orm.github.io/hare-orm/
about: Check the reference before filing a "how do I..." question - it's written directly against the source. / Прежде чем спрашивать "как сделать...", загляните в справочник - он написан по исходному коду.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Feature request / Предложение
description: Propose new behavior, an API addition, or a missing capability. / Предложите новое поведение, дополнение API или недостающую возможность.
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: What's the problem? / В чём задача?
description: What are you trying to do that hare-orm doesn't support today? / Что вы хотите сделать, а hare-orm сейчас этого не умеет?
validations:
required: true

- type: textarea
id: proposal
attributes:
label: Proposed API / Предлагаемый API
description: >
Sketch the API you'd want to use, even roughly - a code snippet is worth more than a
description here.
Набросайте API, которым хотели бы пользоваться, хотя бы примерно, - фрагмент кода здесь
полезнее описания.
render: python

- type: textarea
id: alternatives
attributes:
label: Workarounds you've tried / Какие обходные пути вы пробовали
description: Is there already a way to do this today, just an awkward one? / Можно ли сделать это уже сейчас, пусть и неудобно?
31 changes: 31 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## What & why / Что и зачем

<!-- What does this change, and why is it needed? Link an issue if there is one.
Что меняется и зачем это нужно? Укажите issue, если он есть. -->

## How was this tested? / Как это проверено?

<!-- New/updated tests are expected for anything beyond a trivial fix - which ones, and what do
they cover? If you only ran things manually, say what you ran.
Для всего, кроме мелкого исправления, ожидаются новые или обновлённые тесты - какие и что они
проверяют? Если проверяли только вручную, напишите, что запускали. -->

## Checklist / Чек-лист

- [ ] `make check` passes (style + mypy + bandit) / `make check` проходит
- [ ] `make test_sqlite` passes; `make test_postgres_asyncpg` too if this
touches PostgreSQL / `make test_sqlite` проходит, а если затронут
PostgreSQL - и `make test_postgres_asyncpg`
- [ ] `make docs` passes if this touches `docs/` / `make docs` проходит, если затронута `docs/`
- [ ] Docs updated under `docs/` (both the `.md` and its `.ru.md` sibling) if this changes public
behavior / Документация в `docs/` обновлена (и `.md`, и `.ru.md`), если меняется публичное
поведение
- [ ] A line under `## [Unreleased]` in `CHANGELOG.md` and in `CHANGELOG.ru.md` if this is a
user-visible change (breaking changes under *Breaking changes*, with what to change in
calling code) / Строка в `## [Unreleased]` в `CHANGELOG.md` и `CHANGELOG.ru.md`, если
изменение заметно пользователю (несовместимое - в *Breaking changes*, с тем, что поменять в
вызывающем коде)
- [ ] Every commit is signed off (`git commit -s`, see CONTRIBUTING.md → Sign-off) / Каждый коммит
подписан (`git commit -s`, см. CONTRIBUTING.ru.md → Подпись)
- [ ] No unrelated formatting/reordering churn mixed into the diff / В изменениях нет посторонних
правок форматирования и перестановок
38 changes: 38 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Set up Python and poetry
description: >-
The Python a job runs on, the poetry every job installs hare-orm with (make deps, make matrix_venvs),
make on Windows, and the poetry cache of that Python and poetry.lock.
inputs:
python-version:
description: The Python to set up - a version setup-python takes.
required: true
outputs:
python-path:
description: The path of the Python's executable.
value: ${{ steps.python.outputs.python-path }}
python-version:
description: The exact version set up.
value: ${{ steps.python.outputs.python-version }}
runs:
using: composite
steps:
- uses: actions/setup-python@v6
id: python
with:
python-version: ${{ inputs.python-version }}
- name: Install poetry
shell: bash
run: pipx install poetry==2.1.4
- name: Install make
if: runner.os == 'Windows'
shell: bash
run: command -v make || choco install make --no-progress
- uses: actions/cache@v5
with:
path: |
~/.cache/pypoetry
~/Library/Caches/pypoetry
~/AppData/Local/pypoetry/Cache
key: ${{ runner.os }}-poetry-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-${{ steps.python.outputs.python-version }}-
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
updates:
# Python dependencies (pyproject.toml, poetry.lock). One grouped pull request a week keeps the
# lock file moving without a pull request per package.
- package-ecosystem: pip
directory: /
target-branch: dev
schedule:
interval: weekly
groups:
python-dependencies:
patterns: ["*"]

# The native extension: the PostgreSQL driver, the row readers/writers and the field codecs.
- package-ecosystem: cargo
directories:
- /rust/native
target-branch: dev
schedule:
interval: weekly
groups:
rust-dependencies:
patterns: ["*"]

- package-ecosystem: github-actions
directory: /
target-branch: dev
schedule:
interval: weekly
groups:
github-actions:
patterns: ["*"]
88 changes: 88 additions & 0 deletions .github/scripts/absolute_readme_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""Makes the relative links of README.md absolute, for the package's description on PyPI.

GitHub resolves ``docs/assets/readme-banner-light.png`` and ``LICENSE`` against the repository;
PyPI, showing the README the package carries, has nothing to resolve them against. Before a
release builds the package, this rewrites them to the commit being released: an image to
``https://raw.githubusercontent.com/<repository>/<commit>/<path>``, a link to
``https://github.com/<repository>/blob/<commit>/<path>``. Absolute URLs and ``#anchors`` stay.

Usage:
python .github/scripts/absolute_readme_links.py --repository hare-orm/hare-orm --commit <sha>
"""

from __future__ import annotations

import argparse
import re
from pathlib import Path


class ReadmeLinks:
"""Rewrites the relative links of one README."""

#: A Markdown image or link: ``![alt](target)`` / ``[text](target)``.
MARKDOWN_TARGET = re.compile(r"(?P<image>!?)\[(?P<text>[^\]]*)\]\((?P<target>[^)\s]+)\)")
#: An HTML attribute naming a file: ``src``, ``srcset`` or ``href``.
HTML_TARGET = re.compile(r'(?P<attribute>\b(?:src|srcset|href))="(?P<target>[^"]+)"')

def __init__(self, repository: str, commit: str) -> None:
"""
Args:
repository: The GitHub repository, ``owner/name``.
commit: The commit the links point at.
"""
self.raw_base = f"https://raw.githubusercontent.com/{repository}/{commit}/"
self.blob_base = f"https://github.com/{repository}/blob/{commit}/"

@staticmethod
def is_relative(target: str) -> bool:
"""Whether a link target is a path in the repository."""
return not re.match(r"^[a-z][a-z0-9+.-]*:|^#|^/", target, re.IGNORECASE)

def get_absolute(self, target: str, image: bool) -> str:
"""The absolute URL of a relative target.

Args:
target: The relative target.
image: Whether it is an image - served raw rather than as a GitHub page.

Returns:
The URL.
"""
return (self.raw_base if image else self.blob_base) + target.removeprefix("./")

def rewrite(self, text: str) -> str:
"""The README with its relative links made absolute.

Args:
text: The README.

Returns:
The rewritten README.
"""

def replace_markdown(match: re.Match[str]) -> str:
target = match.group("target")
if not self.is_relative(target):
return match.group(0)
image = bool(match.group("image"))
return f"{match.group('image')}[{match.group('text')}]({self.get_absolute(target, image)})"

def replace_html(match: re.Match[str]) -> str:
target = match.group("target")
if not self.is_relative(target):
return match.group(0)
image = match.group("attribute") in ("src", "srcset")
return f'{match.group("attribute")}="{self.get_absolute(target, image)}"'

return self.HTML_TARGET.sub(replace_html, self.MARKDOWN_TARGET.sub(replace_markdown, text))


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Makes the relative links of README.md absolute.")
parser.add_argument("--repository", required=True, help="The GitHub repository, owner/name.")
parser.add_argument("--commit", required=True, help="The commit the links point at.")
parser.add_argument("--readme", type=Path, default=Path(__file__).resolve().parents[2] / "README.md")
arguments = parser.parse_args()
readme = arguments.readme.read_text(encoding="utf-8")
arguments.readme.write_text(ReadmeLinks(arguments.repository, arguments.commit).rewrite(readme), encoding="utf-8")
Loading
Loading