Commit Graph

35 Commits

Author SHA1 Message Date
Wong Hoi Sing Edison 6e0f81c73f CentOS 7: read_text(encoding='utf-8') (#3625)
With CentOS 7 Python 3.6, running install from source with pip failed:

    sudo podman run -ti --rm centos:7
    yum -y update
    yum -y install epel-release
    yum -y install git python3 python3-devel python3-pip python3-setuptools python3-wheel
    git clone https://github.com/samuelcolvin/pydantic.git
    cd pydantic
    pip3 install .

With following error message:

    [root@c99d0585636c pydantic]# pip3 install .
    Processing /pydantic
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-91v_ixvz-build/setup.py", line 62, in <module>
            history = (THIS_DIR / 'HISTORY.md').read_text()
          File "/usr/lib64/python3.6/pathlib.py", line 1197, in read_text
            return f.read()
          File "/usr/lib64/python3.6/encodings/ascii.py", line 26, in decode
            return codecs.ascii_decode(input, self.errors)[0]
        UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 14648: ordinal not in range(128)

        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-91v_ixvz-build/

This PR add the required `read_text(encoding='utf-8')` for `setup.py`.

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2022-04-02 14:05:12 +01:00
Samuel Colvin 6f46a5a146 drop python3.6 support (#3605)
* drop python3.6 support

* revert small change

* fix 3.7 failures

* more cases and cleanup

* add change description
2022-01-02 13:53:45 +00:00
Eric Jolibois 4a54f393ad Add python 3.10 support (#2885)
* refactor: extra `BaseConfig` and `Extra` in dedicated `config` module

* refactor: clean useless `#noqa: F401`

* refactor: clean useless `#noqa: F811`

* refactor: replace enum check

Error with 3.10
> DeprecationWarning: accessing one member from another is not supported

* refactor: avoid using `distutils` directly

error with python 3.10
> DeprecationWarning: The distutils package is deprecated and slated
> for removal in Python 3.12.
> Use setuptools or check PEP 632 for potential alternatives

* fix: `__annotations__` always exists

* fix: origin of `typing.Hashable` is not `None`

* ci: add run with 3.10.0b2

* docs: add 3.10

* feat: support `|` union operator properly

`|` operator has origin `types.Union` (and not `typing.Union`)

* fix: enum repr is different with 3.10+

* fix: error message changed a bit

change from basic `__init__` to `test_hashable_required.<locals>.MyDataclass.__init__()` (with `__qualname__`)

* fix:  always exists and is not inherited anymore

* fix: avoid calling `asyncio.get_event_loop` directly

With python 3.10, calling it results in
> DeprecationWarning: There is no current event loop

* fix(ci): do not run 3.10 on linux for now

For now it can not be compiled.
Let's just skip the check on linux for now instead of tuning the CI pipeline

* fix(ci): ignore DeprecationWarning raised by `mypy` on windows

* docs: add change file
2021-07-19 14:23:07 +01:00
Peter Roelants 2e2edf4f11 Allow custom CFLAGS and update documentation on reducing size. (#2517)
Squashed commit Co-authored-by: Eric Jolibois <em.jolibois@gmail.com>
2021-06-04 21:42:49 +02:00
Samuel Colvin b7a8ef25c6 fix coverage and make typing-extensions a required dependency (#2368)
* fixing coverage by simplifying Annotated import logic, fix #2367

* avoid checking against annotated if it's None

* make typing-extensions required WIP

* more making typing-extensions required

* fix docs and get_origin for python 3.6

* fix mypy test

* fix docs

* update docs, cleanup and add change

* clean docs/examples/schema_annotated.py

* move AnnotatedTypeNames
2021-02-17 19:17:30 +00:00
Taneli Hukkinen 40a925f30a Fix python_requires metadata to require >=3.6.1 (#2306)
* Fix `python_requires` metadata to require >=3.6.1

* Add changelog entry
2021-02-13 17:14:28 +00:00
Jacob Hayes b742c6f527 Support Annotated type hints and extracting Field from Annotated (#2147)
* Infer root type from Annotated

* Extract Field from Annotated

* Add changelog

* Extend existing get_args/get_origin

* Fix Annotated on py3.6 without typing-extensions

* Handle Ellipsis default

* Fix field reuse after FieldInfo.default mutation

* Fix ci
2021-02-13 16:13:21 +00:00
Zac Hatfield-Dodds 771b0d3d92 Add a Hypothesis plugin (#2097)
* Configure Hypothesis

* Hypothesis plugin docs

* Add Hypothesis plugin

Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2021-02-11 12:33:11 +00:00
Samuel Colvin a25aba26b5 linting as a separate CI step (#2030)
* linting as a separate ci step

* CI and docs improvements

* fix docs preview

* fix docs, benchmarks fastapi tests

* fix formatting and docs build

* tweak publishing docs

* fix for new download-artifact action

* skip check tag to check docs build

* prepare for merge
2020-10-25 15:03:33 +00:00
PrettyWood 794d0bccf9 feat: add basic support for python 3.9 (#1844)
* feat: use partially get_origin and get_args from typing

Rework of d86a184072655d93652d6ea941421005f34de962 by @hmvp
We cannot directly use `typing.get_origin` and `typing.get_args` for
our custom types for which args and origin are wrong by default.
But at least we now have a unified behaviour, which can be improved
in the near future

* feat: add fallback in `get_args` for generics in python 3.9

* feat: add new `_evaluate` for python 3.9

In python 3.9, `typing._evaluate` has a new required
positional argument `recursive_guard`

* chore: add pragma no cover for python 3.9 fallbacks

* chore: add change file

* chore: add comments

* feat(ci): add python 3.9 support

* fix: mypy assumption is wrong
2020-10-18 20:36:18 +01:00
Samuel Colvin 96c9c400bc Move to GitHub actions (#1326)
* trying move to github actions

* move name

* remove travis and cleanup

* macos and windows coverage

* env_vars string

* bump

* bump

* delete old coverage file

* remove coverage.xml

* add 'make test-codecov'

* fix 'make test-codecov'

* beginning build phase

* combined deploy

* try to fix articacts

* remove set.cfg wheel tag

* install cython before build

* fix windows builds

* fix windows builds

* reenable tests

* build docs, test pypi upload

* finalize

* add change description, fix job conditionals
2020-03-21 17:02:07 +00:00
Connor 730d84217d allow use of a .env-style files in BaseSettings (#607) (#1011)
* allow use of a `.env`-style files in BaseSettings (#607)

* address various issues with initial implementation

- allow specifying `_env_file` kwarg in instantiation
  * overrides any `env_file` specified in the `Config` class
- cast `os.environ` as a dict for better consistenty of behavior
- `env_path` should be a `Path` type
- replace `with open()` with `read_text`
- use regex for parsing the dotenv files and throw error on invalid line
- factor out `read_env_file` into separate file for easier testing

* move back into a single file; revert typing changes; use regex better

* pass `_env_file` argument around instead of setting a class attribute

* add dotenv docs

* add dotenv tests

* Add changes file

* Flesh out the docs a bit

* Apply suggestions from @samuelcolvin's code review

Co-Authored-By: Samuel Colvin <samcolvin@gmail.com>

* wrap docs

* add not about priority

* fix tests and imports

* fix tests

* switch to python-dotenv

* cleanup, test example

* more docs tweaks

* typo

* fix tests for dotenv

Co-authored-by: Samuel Colvin <samcolvin@gmail.com>
2020-01-19 16:45:36 +00:00
Samuel Colvin 15b981d05f change cython nthreads default to zero (#1074)
* change cython nthreads default to zero

* add change
2019-12-04 13:30:30 +00:00
Samuel Colvin 33b7d52d31 moving docs to mkdocs (#856)
* moving docs to mkdocs

* transfering readme to md and more

* fixing build

* splitting usage.md

* improving schema.md and index.md

* fix make_history.rst

* models intro

* working on data conversation and required fields

* more fixes to models.md

* list all standard types supported

* list of pydantic types

* tweaks

* update links in code

* Apply suggestions from code review

incorporate @dmontagu's suggestions.

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>

* Apply suggestions from code review

more missed suggestions.

Co-Authored-By: dmontagu <35119617+dmontagu@users.noreply.github.com>

* Apply suggestions from code review

more corrects.

* cleanup

* Field order warning

* fix and regenerate benchmarks

* format examples better, cleanup

* improve schema mapping table

* correct highlighting file types in schema.md

* add redirects in javascript

* add logo
2019-10-07 17:19:01 +01:00
Samuel Colvin 973de05a01 custom json (de)serialisation (#823)
* custom json (d)encoders, fix #714

* add docs
2019-09-30 14:34:30 +01:00
Samuel Colvin 24ac05276b big performance improvement! (#819)
* big performance improvement!

* exception performance improvement

* check errors and explicit export from errors.py

* more tweaks

* fix coverage

* fix tests and remove "from e" in exceptions for performance
2019-09-18 15:00:43 +01:00
Chris Lamb ef894d20b3 Make the build reproducible (#805)
Whilst working on the Reproducible Builds effort [0] we noticed
that pydantic could not be built reproducibly.

This is due to it generating the contents of the `PKG-INFO` file
via iterating over the contents of a set.

This was originally filed in Debian as #940156 [1].

 [0] https://reproducible-builds.org/
 [1] https://bugs.debian.org/940156

Signed-off-by: Chris Lamb <lamby@debian.org>
2019-09-13 10:56:57 +01:00
dmontagu 3ee54ed2bb Add support for Literal annotation (#582)
fix #561

* Add support for Literal annotation

* Updated requirements.txt

* incorporating feedback

* skip typing_extensions tests if not installed

* missed a spot

* address feedback

* Make work with python 3.6

* Work for *both* 3.6 and 3.7

* incorporate feedback

* fixed naming and quotes

* Trying to fix LGTM bot issue
2019-06-25 10:33:21 +01:00
dmontagu b84df079a7 Add generic functionality (#595), fix #556
* Added generic functionality

* Skip tests in python 3.6

* double quote -> single quote

* Simplified, with more comprehensive tests

* double quote -> single quote

* Remove unintentional file

* Add caching

* don't cythonize generics.py

* Make work with mypy

* Remove __parameters__

* double quote -> single quote i'll remember one day

* More cleanup and validation

* Removed unwanted file

* A little more cleanup, and finish the PR

* Add proper inheritance

* Added note about inheritance to docs

* Added error for double-parameterizing

* Should build for python3.7

* Works with both 3.6 and 3.7

* Fixed bug with caching for single argument

* handle __name__ for generic models

* double quote -> single quote

* Updated error messages
2019-06-19 11:22:06 +01:00
Samuel Colvin 3dfae21208 ORM mode: Add support for arbitrary class instances (#562)
* Support ORM objects to 'parse_obj', replace #520

* switch to GetterDict and orm_mode

* tweaks

* update docs

* split tests and add @tiangolo's suggestion

* split tests and add @tiangolo's suggestion

* fix coverage
2019-06-06 11:29:09 +01:00
Samuel Colvin b248a0984f update benchmarks (#563)
* update benchmarks

* optimize
2019-05-30 12:43:44 +01:00
Samuel Colvin d473f4abc9 cython (#548)
* user cython for fields.py, parse.py and validators.py, fix #547

* fix coverage

* no cython on windows

* speedup error_wrappers, more cython

* conditional validators

* more tweaks to validators.py

* add compiled check

* fix mypy and tweak

* benchmark with cython

* simplify anystr_strip_whitespace

* build binaries on travis

* fix travis manylinux builds

* correct test stages

* cibuildwheel to dist

* fix manylinux build

* don't upgrade pip on wheel build

* try a fix for cibuildwheel

* speedup deploy stage

* revert file rearrangement, cythonize main.py

* tweak main.py

* update docs and history

* fix deploy stage of travis

* Cythonize more files (#553)

* Cythonize more files

* Tests pass

* Fixed ordering

* Some code cleanup

* Every last file cythonized

* cython coverage

* upgrade cython and tweak build setup

* different build stages
2019-05-30 12:04:15 +01:00
Samuel Colvin 27323aa8b2 fix for python 3.8 (#396)
* fix for python 3.8

* history and tweak types in main.py
2019-02-15 18:29:13 +00:00
Jere Lahelma db53fad28d add py.typed marker file for PEP-561 support (#391)
Fix #390

Disable zip_safe option as mypy is incompatible with it.
2019-02-13 15:11:33 +00:00
Samuel Colvin 3d4dc90d4b classifiers and python-tag 2018-12-27 23:44:13 +00:00
Samuel Colvin 9ff946d2fa PyObject = None, and Pattern (#306)
* PyObject = None, fix #305

* history formatting on pypi

* fix history rendering in setup

* allow Pattern validation, fix #303

* fix for python3.7

* fix linting

* proper processing for regex pattern errors
2018-11-18 16:11:29 +00:00
Samuel Colvin f3a278bb8d Dataclasses (#269)
* pydantic.dataclasses.dataclass decorator

* add dataclasses to requirnment.txt

* reimplement dataclasses

* fix linting, fix coverage

* docs
2018-10-01 09:48:28 +01:00
Samuel Colvin 9338c413c7 remove msgpack (#201)
* remove msgpack

* update history
2018-06-18 12:20:10 +01:00
Samuel Colvin afb90b91e8 implement email validator (#142)
* implement email validator, replace #112

* coverage and cleanup

* update docs
2018-03-25 18:09:37 +01:00
Samuel Colvin bf80464f28 allow direct install, fix #106 (#107) 2017-11-26 16:27:15 +00:00
Samuel Colvin 13300cd8c6 add .pyup.yml, tweak setup 2017-10-23 16:06:16 +01:00
Samuel Colvin 044fd42f4f parser methods (#58), fix #39
* working on parsers

* starting parse tests

* proper tests for parse

* adding parse docs

* tweaks and history

* add test for datetime direct, fix tests

* tweak docs
2017-07-08 18:39:24 +01:00
Thomas Grainger 3544c351ec configure python_requires and py3 only trove (#32) 2017-06-04 00:08:46 +01:00
Samuel Colvin 6d2e6b6d60 linting and adding .travis.yml 2017-05-05 12:19:25 +01:00
Samuel Colvin a8e844dad5 initial commit 2017-05-03 22:23:41 +01:00