Skip to content

Commit

Permalink
fix: Fix github ci (#40)
Browse files Browse the repository at this point in the history
Turns out it's already should be using github-ci, we need only minor fixes.
  • Loading branch information
last-partizan authored Jul 25, 2023
1 parent 9b3a693 commit 2a44546
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 82 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Taken from: https://jacobian.org/til/github-actions-poetry/
on: push
on:
push:
branches:
- master
pull_request:

jobs:
test:
Expand All @@ -14,11 +17,11 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-1.1.9-0
key: poetry-1.5.1-1

- uses: snok/install-poetry@v1
with:
version: 1.1.9
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

Expand All @@ -35,14 +38,6 @@ jobs:
- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: "package.json"
cache: "yarn"

- run: yarn install --frozen-lockfile --non-interactive

# Now install _your_ project. This isn't necessary for many types of projects -- particularly
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
# pyproject.toml and makes that if you add things like console-scripts at some point that
Expand All @@ -51,4 +46,3 @@ jobs:

- name: lint
run: ./s/lint

14 changes: 0 additions & 14 deletions package.json

This file was deleted.

102 changes: 69 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ packages = [
python = "^3.7"
typing_extensions = { version = "^4.6", python = "<3.11" }

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
ipython = "^7.19"
django-types = "^0.3.1"
django = "^3.1"
flake8 = "^3.8"
flake8-pyi = "^20.10"
mypy = "^0.982"
mypy = "^1.4"
isort = "5.10.1"
black = "^22.10.0"
types-requests = "^2.28.11"
ruff = "^0.0.261"
pyright = "^1.1.318"

[tool.black]
line-length = 120
Expand Down Expand Up @@ -82,7 +83,7 @@ unfixable = [
"ERA001",
] # we want to check ourselves before we delete commented out code.
update-check = false
target-version = "py311"
target-version = "py38"

[tool.ruff.flake8-tidy-imports]
# Disallow all relative imports.
Expand Down
1 change: 1 addition & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"reportUntypedBaseClass": false,
"reportMissingImports": false,
"reportUnknownVariableType": false,
"reportUnusedImport": false,
"reportInvalidTypeVarUse": false,
"reportGeneralTypeIssues": false,
"reportUnknownArgumentType": false,
Expand Down
3 changes: 1 addition & 2 deletions rest_framework-stubs/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ _ThrottleClassesParam = Sequence[type[BaseThrottle]]

def throttle_classes(throttle_classes: _ThrottleClassesParam) -> Callable[[_F], _F]: ...

# probably a bug
_PermClassesParam = Sequence[type[_PermissionClass]] # type: ignore [misc]
_PermClassesParam = Sequence[_PermissionClass]

def permission_classes(permission_classes: _PermClassesParam) -> Callable[[_F], _F]: ...

Expand Down
1 change: 0 additions & 1 deletion rest_framework-stubs/fields.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ from typing import (

from django.core.files.base import File
from django.db import models
from django.forms import ImageField as DjangoImageField # noqa: F401
from rest_framework.serializers import BaseSerializer

class _Empty(Enum):
Expand Down
2 changes: 1 addition & 1 deletion rest_framework-stubs/request.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Request(HttpRequest):
def query_params(self) -> QueryDict: ...
@property
def data(self) -> dict[str, Any]: ...
@property # type: ignore[override]
@property
def user(self) -> AbstractBaseUser | AnonymousUser: ...
@user.setter
def user(self, value: AbstractBaseUser | AnonymousUser) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion rest_framework-stubs/serializers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from typing import (
Literal,
NoReturn,
)
from typing_extensions import Self

from django.db import models
from django.db.models import Manager, QuerySet
Expand Down Expand Up @@ -73,6 +72,7 @@ from rest_framework.relations import SlugRelatedField as SlugRelatedField
from rest_framework.relations import StringRelatedField as StringRelatedField
from rest_framework.utils.model_meta import FieldInfo, RelationInfo
from rest_framework.utils.serializer_helpers import BoundField, ReturnList
from typing_extensions import Self

LIST_SERIALIZER_KWARGS: Sequence[str] = ...
ALL_FIELDS: str = ...
Expand Down
2 changes: 1 addition & 1 deletion s/lint
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
./.venv/bin/ruff . --fix
fi

./node_modules/.bin/pyright tests typings
./.venv/bin/pyright tests typings

# type check code
./.venv/bin/mypy tests typings
17 changes: 12 additions & 5 deletions tests/test_restframework.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from rest_framework import status
from rest_framework.decorators import permission_classes
from rest_framework.permissions import IsAdminUser, IsAuthenticated
from rest_framework.test import APIClient
from typing_extensions import assert_type


def test_restframework_types() -> None:
def test_test_client_types() -> None:
client = APIClient()

res = client.get("/api/v1/foo")
assert res.status_code == status.HTTP_200_OK
print(res.data)
assert res.json() == {"test": "foo"}

assert_type(res.status_code, int)


def test_decorator_types() -> None:
permission_classes([IsAuthenticated])
permission_classes([IsAuthenticated | IsAdminUser])
8 changes: 0 additions & 8 deletions yarn.lock

This file was deleted.

0 comments on commit 2a44546

Please sign in to comment.