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

Add mypy check #720

Merged
merged 4 commits into from
Jul 28, 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
52 changes: 39 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,62 @@ on:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install Poetry
run: pipx install poetry

- name: Set Poetry config
run: |
poetry config virtualenvs.path ~/.virtualenvs3.11

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: 3.11
cache: "poetry"

- name: Install dependencies
run: poetry install

- name: ruff check
run: poetry run ruff check .

- name: mypy check
run: poetry run mypy django_unicorn

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.1.4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.6
with:
poetry-version: 1.6.1
run: pipx install poetry

- name: Set Poetry config
run: |
poetry config virtualenvs.path ~/.virtualenvs${{ matrix.python-version }}

- name: Install dependencies
run: poetry install
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: ruff check
run: poetry run ruff check .
- name: Install dependencies
run: poetry install -E minify

- name: Run all tests
run: poetry run nox
15 changes: 10 additions & 5 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developing

## Local Development
## Local development

1. Fork https://github.com/adamghill/django-unicorn`
1. `git clone` your forked repository
Expand All @@ -10,26 +10,31 @@
1. `poetry run python example/manage.py runserver localhost:8000`
1. Go to `localhost:8000` in your browser

## To Install in Another Project
## To install in another project

1. Download the repo to your local
1. `pip install -e ../django-unicorn` from inside the other project's virtualenv _or_ add `django-unicorn = { path="../django-unicorn", develop=true }` to the other project's `pyproject.toml`

## Build Sphinx Documentation
## Build Sphinx documentation

1. `poetry run sphinx-autobuild -W docs/source docs/build`

## Run Unittests
## Run unit tests on local environment

1. Python: `poetry run pytest`
1. JavaScript: `npm run test`

## Run Python/Django matrix unit tests

1. Install [`act`](https://nektosact.com)
1. `act -q -j test -W .github/workflows/python.yml`

# Minify JavaScript

1. `npm install`
1. `npm run build`

## Bump Version
## Bump version

1. Update changelog.md
1. Update package.json
Expand Down
3 changes: 2 additions & 1 deletion django_unicorn/components/unicorn_template_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import re
from collections import deque
from typing import Deque

import orjson
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -48,7 +49,7 @@ def is_html_well_formed(html: str) -> bool:
"""

tag_list = re.split("(<[^>!]*>)", html)[1::2]
stack: deque[str] = deque()
stack: Deque[str] = deque()

for tag in tag_list:
if "/" not in tag:
Expand Down
Loading