Skip to content

Commit

Permalink
Generate docs exampels for Python 3.10 and above (#4339)
Browse files Browse the repository at this point in the history
* Generate docs exampels for Python 3.10 and above

Code quality is not great and main intent here is to show the result.

* Fix docs build on 3.9

* Build docs on 3.10

* What's Python 3.1?

* Create temp dir if not exists

* Refactor and improve imlementetion

* Keep runtime typing in examples

* Revert unrelated formatting changes

* Add changes file

* Allow specifying requirements in examples

* Pin autoflake and pyupgrade

* Add docs/build to Makefile lint/format/mypy

* ignore_missing_imports for ansi2html and devtools

* Add .tmp-projections to .gitignore

* Remove dont-upgrade now when Pattern is supported

* Update postponed evaluation examples

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
  • Loading branch information
Bobronium and samuelcolvin committed Aug 14, 2022
1 parent 11903e3 commit c24d33e
Show file tree
Hide file tree
Showing 35 changed files with 664 additions and 919 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: set up python
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: "3.10"

- uses: actions/cache@v3
id: cache
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -21,6 +21,8 @@ test.py
/docs/.version.md
/docs/.tmp_schema_mappings.html
/docs/.tmp_examples/
/docs/.tmp-projections/
/docs/usage/.tmp-projections/
/site/
/site.zip
.pytest_cache/
Expand Down
11 changes: 6 additions & 5 deletions Makefile
@@ -1,6 +1,7 @@
.DEFAULT_GOAL := all
isort = isort pydantic tests
black = black -S -l 120 --target-version py38 pydantic tests
sources = pydantic tests docs/build
isort = isort $(sources)
black = black -S -l 120 --target-version py38 $(sources)

.PHONY: install-linting
install-linting:
Expand Down Expand Up @@ -35,13 +36,13 @@ build:

.PHONY: format
format:
pyupgrade --py37-plus --exit-zero-even-if-changed `find pydantic tests -name "*.py" -type f`
pyupgrade --py37-plus --exit-zero-even-if-changed `find $(sources) -name "*.py" -type f`
$(isort)
$(black)

.PHONY: lint
lint:
flake8 pydantic/ tests/
flake8 $(sources)
$(isort) --check-only --df
$(black) --check --diff

Expand All @@ -53,7 +54,7 @@ check-dist:

.PHONY: mypy
mypy:
mypy pydantic
mypy pydantic docs/build

.PHONY: pyupgrade
pyupgrade:
Expand Down
1 change: 1 addition & 0 deletions changes/4339-Bobronium.md
@@ -0,0 +1 @@
Add Python 3.9 and 3.10 examples to docs

0 comments on commit c24d33e

Please sign in to comment.