Skip to content

Commit dae9325

Browse files
committed
revert removing python 3.6, #3605
1 parent 8846ec4 commit dae9325

30 files changed

+260
-85
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
strategy:
101101
fail-fast: false
102102
matrix:
103-
python-version: ['3.7', '3.8', '3.9', '3.10']
103+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
104104
env:
105105
PYTHON: ${{ matrix.python-version }}
106106
OS: ubuntu
@@ -155,9 +155,7 @@ jobs:
155155
fail-fast: false
156156
matrix:
157157
os: [ubuntu, macos, windows]
158-
python-version: ['3.7', '3.8', '3.9', '3.10']
159-
include:
160-
- os: ubuntu
158+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
161159

162160
env:
163161
PYTHON: ${{ matrix.python-version }}
@@ -310,7 +308,7 @@ jobs:
310308
fail-fast: false
311309
matrix:
312310
os: [ubuntu , macos , windows]
313-
python-version: ['7', '8', '9', '10']
311+
python-version: ['6', '7', '8', '9', '10']
314312
include:
315313
- os: ubuntu
316314
platform: linux

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Data validation and settings management using Python type hints.
1212

1313
Fast and extensible, *pydantic* plays nicely with your linters/IDE/brain.
14-
Define how data should be in pure, canonical Python 3.7+; validate it with *pydantic*.
14+
Define how data should be in pure, canonical Python 3.6+; validate it with *pydantic*.
1515

1616
## Help
1717

changes/3605-samuelcolvin.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To make contributing as easy and fast as possible, you'll want to run tests and
3333
*pydantic* has few dependencies, doesn't require compiling and tests don't need access to databases, etc.
3434
Because of this, setting up and running the tests should be very simple.
3535

36-
You'll need to have a version between **python 3.7 and 3.10**, **virtualenv**, **git**, and **make** installed.
36+
You'll need to have a version between **python 3.6 and 3.10**, **virtualenv**, **git**, and **make** installed.
3737

3838
```bash
3939
# 1. clone your fork and cd into the repo directory
@@ -44,7 +44,7 @@ cd pydantic
4444
virtualenv -p `which python3.8` env
4545
source env/bin/activate
4646
# Building docs requires 3.8. If you don't need to build docs you can use
47-
# whichever version; 3.7 will work too.
47+
# whichever version; 3.6 will work too.
4848

4949
# 3. Install pydantic, dependencies, test dependencies and doc dependencies
5050
make install

docs/install.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ Installation is as simple as:
44
pip install pydantic
55
```
66

7-
*pydantic* has no required dependencies except python 3.7, 3.8, 3.9 or 3.10 and
8-
[`typing-extensions`](https://pypi.org/project/typing-extensions/).
9-
If you've got python 3.7+ and `pip` installed, you're good to go.
7+
*pydantic* has no required dependencies except python 3.6, 3.7, 3.8, 3.9 or 3.10,
8+
[`typing-extensions`](https://pypi.org/project/typing-extensions/), and the
9+
[`dataclasses`](https://pypi.org/project/dataclasses/) backport package for python 3.6.
10+
If you've got python 3.6+ and `pip` installed, you're good to go.
1011

1112
Pydantic is also available on [conda](https://www.anaconda.com) under the [conda-forge](https://conda-forge.org)
1213
channel:

docs/usage/dataclasses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
If you don't want to use _pydantic_'s `BaseModel` you can instead get the same data validation on standard
22
[dataclasses](https://docs.python.org/3/library/dataclasses.html) (introduced in python 3.7).
33

4+
Dataclasses work in python 3.6 using the [dataclasses backport package](https://github.com/ericvsmith/dataclasses).
5+
46
```py
57
{!.tmp_examples/dataclasses_main.py!}
68
```

docs/usage/models.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ For example, in the example above, if `_fields_set` was not provided,
296296

297297
Pydantic supports the creation of generic models to make it easier to reuse a common model structure.
298298

299+
!!! warning
300+
Generic models are only supported with python `>=3.7`, this is because of numerous subtle changes in how
301+
generics are implemented between python 3.6 and python 3.7.
302+
299303
In order to declare a generic model, you perform the following steps:
300304

301305
* Declare one or more `typing.TypeVar` instances to use to parameterize your model.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
site_name: pydantic
2-
site_description: Data validation and settings management using python type hints
2+
site_description: Data validation and settings management using python 3.6 type hinting
33
strict: true
44
site_url: https://pydantic-docs.helpmanual.io/
55

pydantic/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from enum import Enum
3-
from typing import TYPE_CHECKING, Any, Callable, Dict, ForwardRef, Optional, Tuple, Type, Union
3+
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Tuple, Type, Union
44

55
from .typing import AnyCallable
66
from .utils import GetterDict
@@ -59,7 +59,8 @@ class BaseConfig:
5959
schema_extra: Union[Dict[str, Any], 'SchemaExtraCallable'] = {}
6060
json_loads: Callable[[str], Any] = json.loads
6161
json_dumps: Callable[..., str] = json.dumps
62-
json_encoders: Dict[Union[Type[Any], str, ForwardRef], AnyCallable] = {}
62+
# key type should include ForwardRef, but that breaks with python3.6
63+
json_encoders: Dict[Union[Type[Any], str], AnyCallable] = {}
6364
underscore_attrs_are_private: bool = False
6465

6566
# whether inherited models as fields should be reconstructed as base model

pydantic/fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,7 @@ def is_complex(self) -> bool:
11381138
def _type_display(self) -> PyObjectStr:
11391139
t = display_as_type(self.type_)
11401140

1141+
# have to do this since display_as_type(self.outer_type_) is different (and wrong) on python 3.6
11411142
if self.shape in MAPPING_LIKE_SHAPES:
11421143
t = f'Mapping[{display_as_type(self.key_field.type_)}, {t}]' # type: ignore
11431144
elif self.shape == SHAPE_TUPLE:

0 commit comments

Comments
 (0)