Skip to content

Commit

Permalink
migrate to python3.8
Browse files Browse the repository at this point in the history
Closes: #121
  • Loading branch information
m.kindritskiy committed Sep 15, 2024
1 parent 9058f0a commit e2179a7
Show file tree
Hide file tree
Showing 24 changed files with 976 additions and 946 deletions.
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
30 changes: 24 additions & 6 deletions hiku/endpoint/graphql.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Optional, List, Dict, Union, overload
from typing_extensions import TypedDict
from typing import Any, Optional, List, Dict, Union, overload, TypedDict

from abc import ABC
from asyncio import gather
Expand Down Expand Up @@ -59,11 +58,17 @@ def dispatch(
) -> GraphQLResponse:
"""
Dispatch graphql request to graph
Args:
data: {"query": str, "variables": dict, "operationName": str}
context: context for operation
Returns: graphql response: data or errors
Example:
.. code-block:: python
result = endpoint.dispatch({"query": "{ hello }"})
:param dict data:
{"query": str, "variables": dict, "operationName": str}
:param dict context: context for operation
:return: :py:class:`dict` graphql response: data or errors
"""
assert "query" in data, "query is required"
result = self.schema.execute_sync(
Expand All @@ -79,6 +84,19 @@ class BaseAsyncGraphQLEndpoint(BaseGraphQLEndpoint):
async def dispatch(
self, data: GraphQLRequest, context: Optional[Dict] = None
) -> GraphQLResponse:
"""Dispatch graphql request to graph
Example:
.. code-block:: python
result = await endpoint.dispatch({"query": "{ hello }"})
:param dict data:
{"query": str, "variables": dict, "operationName": str}
:param dict context: context for operation
:return: :py:class:`dict` graphql response: data or errors
"""
assert "query" in data, "query is required"
result = await self.schema.execute(
query=data["query"],
Expand Down
4 changes: 2 additions & 2 deletions hiku/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from abc import ABC, abstractmethod
from enum import Enum
from itertools import chain
from functools import reduce
from functools import reduce, cached_property
from collections import OrderedDict, defaultdict
from typing import List

Expand All @@ -39,7 +39,6 @@
UnionRefMeta,
)
from .utils import (
cached_property,
const,
Const,
)
Expand Down Expand Up @@ -865,6 +864,7 @@ def accept(self, visitor: "AbstractGraphVisitor") -> t.Any:
def from_graph(cls: t.Type[G], other: G, root: Root) -> G:
"""Create graph from other graph, with new root node.
Useful for creating mutation graph from query graph.
Example:
MUTATION_GRAPH = Graph.from_graph(QUERY_GRAPH, Root([...]))
"""
Expand Down
11 changes: 4 additions & 7 deletions hiku/introspection/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import typing as t

from functools import partial
from functools import partial, cached_property
from collections import OrderedDict

from ..directives import (
Expand Down Expand Up @@ -49,10 +49,7 @@
UnionRefMeta,
)
from ..types import Any, RecordMeta, AbstractTypeVisitor
from ..utils import (
listify,
cached_property,
)
from ..utils import listify
from .types import (
ENUM,
EnumValueIdent,
Expand Down Expand Up @@ -629,7 +626,7 @@ def directive_value_info(
schema: SchemaInfo,
fields: t.List[Field],
ids: t.List[DIRECTIVE], # type: ignore[valid-type]
) -> t.Iterator[t.List[Any]]:
) -> t.Iterator[t.List[t.Any]]:
for ident in ids:
if ident.name in schema.directives_map: # type: ignore[attr-defined]
info = schema.directives_map[ident.name].__directive_info__ # type: ignore # noqa: E501
Expand Down Expand Up @@ -658,7 +655,7 @@ def enum_value_info(
schema: SchemaInfo,
fields: t.List[Field],
ids: t.List[EnumValueIdent], # type: ignore[valid-type]
) -> t.Iterator[t.List[Any]]:
) -> t.Iterator[t.List[t.Any]]:
for ident in ids:
enum = schema.query_graph.enums_map[ident.enum_name] # type: ignore[attr-defined] # noqa: E501
value = enum.values_map[ident.value_name] # type: ignore[attr-defined]
Expand Down
Loading

0 comments on commit e2179a7

Please sign in to comment.