Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to python3.8 #166

Merged
merged 4 commits into from
Sep 15, 2024
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
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ extend-ignore = E203,E231
ignore =
F811,
W503,
E701,
E704
70 changes: 35 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Check prerelease
id: check_version
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9.]+rc[0-9]+$ ]]; then
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "PRERELEASE=false" >> $GITHUB_OUTPUT
fi
- name: Get Changelog
id: get-changelog
run: |
tags=$(git tag --sort=-version:refname | head -n 2 | awk '{print $1}')
tag_from=$(echo "$tags" | sed -n '2p')
tag_to=$(echo "$tags" | sed -n '1p')
git log --oneline --decorate "${tag_from}..${tag_to}" | tail -n +2 | awk '{print "* "$0}' > .changelog.md
- name: Create Release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: .changelog.md
draft: false
prerelease: ${{ steps.check_version.outputs.PRERELEASE }}
- name: Set up PDM
run: pip install pdm==2.10.4
- name: Publish package distributions to PyPI
run: pdm publish -u "__token__" -P ${{ secrets.TWINE_PASSWORD }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Check prerelease
id: check_version
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/v[0-9.]+rc[0-9]+$ ]]; then
echo "PRERELEASE=true" >> $GITHUB_OUTPUT
else
echo "PRERELEASE=false" >> $GITHUB_OUTPUT
fi
- name: Get Changelog
id: get-changelog
run: |
tags=$(git tag --sort=-version:refname | head -n 2 | awk '{print $1}')
tag_from=$(echo "$tags" | sed -n '2p')
tag_to=$(echo "$tags" | sed -n '1p')
git log --oneline --decorate "${tag_from}..${tag_to}" | tail -n +2 | awk '{print "* "$0}' > .changelog.md
- name: Create Release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: .changelog.md
draft: false
prerelease: ${{ steps.check_version.outputs.PRERELEASE }}
- name: Set up PDM
run: pip install pdm==2.10.4
- name: Publish package distributions to PyPI
run: pdm publish -u "__token__" -P ${{ secrets.TWINE_PASSWORD }}
62 changes: 31 additions & 31 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up PDM
run: pip install pdm==2.10.4
- name: Install dependencies
run: |
pdm sync -d -G test -G dev
pip install tox tox-pdm tox-gh-actions
- name: Run flake8
if: startsWith(matrix.python-version, '3.7')
run: pdm run flake
- name: Run mypy
if: startsWith(matrix.python-version, '3.7')
run: pdm run mypy
- name: Run black
if: startsWith(matrix.python-version, '3.7')
run: pdm run fmt --check
- name: Run unit tests
run: tox run -- --cov-report=term
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up PDM
run: pip install pdm==2.10.4
- name: Install dependencies
run: |
pdm sync -d -G test -G dev
pip install tox tox-pdm tox-gh-actions
- name: Run flake8
if: startsWith(matrix.python-version, '3.8')
run: pdm run flake
- name: Run mypy
if: startsWith(matrix.python-version, '3.8')
run: pdm run mypy
- name: Run black
if: startsWith(matrix.python-version, '3.8')
run: pdm run fmt --check
- name: Run unit tests
run: tox run -- --cov-report=term

federation-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Lets
uses: lets-cli/[email protected]
with:
version: latest
- name: Test federation compatibility
run: timeout 600 lets federation-compatibility-test
- uses: actions/checkout@v3
- name: Install Lets
uses: lets-cli/[email protected]
with:
version: latest
- name: Test federation compatibility
run: timeout 600 lets federation-compatibility-test
5 changes: 2 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ build:
tools:
python: "3.10"
commands:
- pip install pdm==2.6
- pdm sync -G docs
- pip install pdm==2.7.4
- pdm sync -G dev -G docs
- pdm run docs
- mkdir -p _readthedocs
- mv docs/build _readthedocs/html

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM python:3.7.13-slim as base
FROM python:3.8.18-slim as base

WORKDIR /work

ENV PIP_VERSION=23.1.2
ENV PDM_VERSION=2.6
ENV PDM_VERSION=2.7.4
ENV PDM_USE_VENV=no
ENV PYTHONPATH=/work/__pypackages__/3.7/lib
ENV PYTHONPATH=/work/__pypackages__/3.8/lib

RUN apt-get update && apt-get install -y libpq-dev && \
pip install --upgrade pip==${PIP_VERSION} && pip install pdm==${PDM_VERSION}
Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ services:
- postgres
command: pdm run test-all

test-pg:
<<: *test-base
depends_on:
- postgres
command: pdm run test-pg

postgres:
image: postgres:13-alpine
init: true
Expand Down
2 changes: 1 addition & 1 deletion docs/asyncio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ Testing many to one link:
:lines: 189-219
:dedent: 4

.. _aiopg: http://aiopg.readthedocs.io/en/stable/
.. _aiopg: https://aiopg.readthedocs.io/en/stable/
2 changes: 1 addition & 1 deletion docs/changelog/changes_02.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ Backward-incompatible changes
:py:class:`hiku.graph.Option` now is required


.. _aiopg: http://aiopg.readthedocs.io/
.. _aiopg: https://aiopg.readthedocs.io/
2 changes: 2 additions & 0 deletions docs/changelog/changes_08.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Changes in 0.8
- Move `GraphQLError` to `hiku.error` module
- Drop `GraphQLError.errors` field. Earlier we used to store multiple errors in single `GraphQLError` but now its one message - one `GraphQLError`.
- Add `GraphQLError.message` field
- Dropped support for Python 3.7, which ended support on 2023-06-27

Backward-incompatible changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -38,3 +39,4 @@ Backward-incompatible changes
- Move `GraphQLError` to `hiku.error` module
- Drop `GraphQLError.errors` field
- Add `GraphQLError.message` field
- Dropped support for Python 3.7, which ended support on 2023-06-27
8 changes: 2 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx_inline_tabs",
]

autoclass_content = "both"
autodoc_member_order = "bysource"

intersphinx_mapping = {
"python": ("https://docs.python.org/3.6", None),
"aiopg": ("http://aiopg.readthedocs.io/en/stable", None),
"aiopg": ("https://aiopg.readthedocs.io/en/stable", None),
"sqlalchemy": ("http://docs.sqlalchemy.org/en/rel_1_1", None),
}

Expand All @@ -24,8 +25,3 @@
html_theme = "furo"
html_static_path = ["_static"]
html_theme_options = {}


def setup(app):
app.add_css_file("style.css?r=1")
app.add_css_file("fixes.css?r=1")
6 changes: 3 additions & 3 deletions docs/directives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ Built-in schema directives

Example of `@deprecated` directive in graphql

.. code-block::
.. code-block:: graphql

type Order
type Order {
id: ID!
state: String!
status: Int! @deprecated(reason: "Use 'state' instead")
Expand Down Expand Up @@ -133,4 +133,4 @@ You can also define your own directives (reimplementation of `Deprecated` direct
Note that type annotations for fields such as `why: int` are required, because `hiku`
will use them to generate types for schema introspection.

Also you can omit `name='why`, and `hiku` will then use the name of the field in the class automatically.
Also you can omit `name='why`, and `hiku` will then use the name of the field in the class automatically.
8 changes: 4 additions & 4 deletions examples/federation-compatibility/federation.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM python:3.7.13-slim as base
FROM python:3.8.18-slim as base

WORKDIR /work

ENV PIP_VERSION=23.1.2
ENV PDM_VERSION=2.6
ENV PDM_VERSION=2.7.4
ENV PDM_USE_VENV=no
ENV PYTHONPATH=/work/__pypackages__/3.7/lib
ENV PYTHONPATH=/work/__pypackages__/3.8/lib

RUN apt-get update && apt-get install -y libpq-dev gcc && \
pip install --upgrade pip==${PIP_VERSION} && pip install pdm==${PDM_VERSION}
pip install --upgrade pip==${PIP_VERSION} && pip install pdm==${PDM_VERSION}

# for pyproject.toml to extract version
COPY hiku/__init__.py ./hiku/__init__.py
Expand Down
3 changes: 1 addition & 2 deletions examples/federation-compatibility/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ def resolve_reference_direct(representations):
compose=True,
import_url="https://myspecs.dev/myCustomDirective/v1.0",
)
class Custom(FederationSchemaDirective):
...
class Custom(FederationSchemaDirective): ...


QUERY_GRAPH = Graph(
Expand Down
5 changes: 2 additions & 3 deletions hiku/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
Iterator,
Optional,
Callable,
Protocol,
)

from prometheus_client import Counter

from hiku.compat import Protocol
from hiku.result import Index
from hiku.graph import (
Many,
Expand Down Expand Up @@ -55,8 +55,7 @@


class Hasher(Protocol):
def update(self, data: bytes) -> None:
...
def update(self, data: bytes) -> None: ...


CacheKeyFn = Callable[["Context", Hasher], None]
Expand Down
28 changes: 0 additions & 28 deletions hiku/compat.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,16 @@
import sys
import ast as _ast
from typing import Any

PY38: bool = sys.version_info >= (3, 8)
PY310: bool = sys.version_info >= (3, 10)


class _AST:
def __getattr__(self, name: str) -> Any:
return getattr(_ast, name)

if PY38:
arguments = _ast.arguments
else:

@staticmethod
def arguments(_, args, vararg, kwonlyargs, kw_defaults, kwarg, defaults): # type: ignore[no-untyped-def] # noqa
return _ast.arguments(
args, vararg, kwonlyargs, kw_defaults, kwarg, defaults
) # noqa


ast = _AST()

if sys.version_info >= (3, 10):
from typing import Concatenate, ParamSpec, TypeAlias
else:
from typing_extensions import Concatenate, ParamSpec, TypeAlias

if sys.version_info >= (3, 8):
from typing import Protocol
else:
from typing_extensions import Protocol


__all__ = [
"PY38",
"PY310",
"ast",
"Protocol",
"Concatenate",
"ParamSpec",
"TypeAlias",
Expand Down
Loading
Loading