typedpy 2.2.0__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/__init__.cpython-39.pyc +0 -0
  2. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/commons.cpython-39.pyc +0 -0
  3. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/extfields.cpython-39.pyc +0 -0
  4. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/fields.cpython-39.pyc +0 -0
  5. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/json_schema_mapping.cpython-39.pyc +0 -0
  6. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/serialization.cpython-39.pyc +0 -0
  7. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/serialization_wrappers.cpython-39.pyc +0 -0
  8. home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy/__pycache__/structures.cpython-39.pyc +0 -0
  9. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/fields.py +8 -2
  10. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/structures.py +8 -0
  11. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy-2.2.2-py3.9.egg-info}/PKG-INFO +2 -2
  12. typedpy-2.2.0/README.md +0 -76
  13. typedpy-2.2.0/setup.cfg +0 -36
  14. typedpy-2.2.0/setup.py +0 -43
  15. typedpy-2.2.0/typedpy.egg-info/PKG-INFO +0 -98
  16. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/__init__.py +0 -0
  17. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/commons.py +0 -0
  18. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/extfields.py +0 -0
  19. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/json_schema_mapping.py +0 -0
  20. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/serialization.py +0 -0
  21. {typedpy-2.2.0 → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages}/typedpy/serialization_wrappers.py +0 -0
  22. {typedpy-2.2.0/typedpy.egg-info → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy-2.2.2-py3.9.egg-info}/SOURCES.txt +0 -0
  23. {typedpy-2.2.0/typedpy.egg-info → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy-2.2.2-py3.9.egg-info}/dependency_links.txt +0 -0
  24. {typedpy-2.2.0/typedpy.egg-info → home/dannyloya/github/typedpy/venv39/lib/python3.9/site-packages/typedpy-2.2.2-py3.9.egg-info}/top_level.txt +0 -0
@@ -280,12 +280,18 @@ class String(TypedField):
280
280
 
281
281
  class Function(Field):
282
282
  """
283
- A function. Note that this can't be any callable (it can't be a class, for example), but a real function
283
+ A function or method. Note that this can't be any callable (it can't be a class, for example), but a real function
284
284
  """
285
285
 
286
+ _bound_method_type = type(Field().__init__)
287
+
286
288
  def __set__(self, instance, value):
287
289
  def is_function(f):
288
- return type(f) == type(lambda x: x) or type(f) == type(open)
290
+ return type(f) in {
291
+ type(lambda x: x),
292
+ type(open),
293
+ Function._bound_method_type,
294
+ }
289
295
 
290
296
  def err_prefix():
291
297
  return (
@@ -20,6 +20,7 @@ ADDITIONAL_PROPERTIES = "_additionalProperties"
20
20
  IS_IMMUTABLE = "_immutable"
21
21
  OPTIONAL_FIELDS = "_optional"
22
22
  MUST_BE_UNIQUE = "_must_be_unique"
23
+ IGNORE_NONE_VALUES = "_ignore_none"
23
24
  MAX_NUMBER_OF_INSTANCES_TO_VERIFY_UNIQUENESS = 100000
24
25
 
25
26
  py_version = sys.version_info[0:2]
@@ -419,6 +420,7 @@ def _instantiate_fields_if_needed(cls_dict: dict, defaults: dict):
419
420
  IS_IMMUTABLE,
420
421
  DEFAULTS,
421
422
  OPTIONAL_FIELDS,
423
+ IGNORE_NONE_VALUES,
422
424
  }
423
425
  and not isinstance(val, Field)
424
426
  and not key.startswith("__")
@@ -686,6 +688,10 @@ class Structure(UniqueMixin, metaclass=StructMeta):
686
688
  # this raises an exception:
687
689
  Foo(id = 1, a = 2)
688
690
 
691
+ _ignore_none(bool): optional
692
+ Ignore assignment to None for any field value.
693
+ Default is False.
694
+
689
695
  Decorating it with @unique ensures that no all instances of this structure will be unique. It
690
696
  will raise an exception otherwise (see "Uniqueness" section).
691
697
  """
@@ -717,6 +723,8 @@ class Structure(UniqueMixin, metaclass=StructMeta):
717
723
  if key in self.__dict__:
718
724
  raise ValueError("Structure is immutable")
719
725
  value = deepcopy(value)
726
+ if getattr(self, IGNORE_NONE_VALUES, False) and value is None:
727
+ return
720
728
  super().__setattr__(key, value)
721
729
 
722
730
  if (
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedpy
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Type-safe Python
5
5
  Home-page: http://github.com/loyada/typedpy
6
6
  Author: Danny Loya
7
7
  Author-email: dan.loya@gmail.com
8
8
  License: MIT
9
- Download-URL: https://github.com/loyada/typedpy/archive/v2.2.0.tar.gz
9
+ Download-URL: https://github.com/loyada/typedpy/archive/v2.2.2.tar.gz
10
10
  Description: [![][travis img]][travis]
11
11
  [![][docs img]][docs]
12
12
 
typedpy-2.2.0/README.md DELETED
@@ -1,76 +0,0 @@
1
- [![][travis img]][travis]
2
- [![][docs img]][docs]
3
-
4
- [![][coverage img]][coverage]
5
- [![][mutation img]][mutation]
6
-
7
- ![pylint img]
8
-
9
-
10
- [![][license img]][license]
11
-
12
- [![][conda-forge img]][conda-forge]
13
- [![][pypi img]][pypi]
14
-
15
-
16
- ## Typedpy - Strict Type System for Python
17
-
18
- ``typedpy`` is a library for type-safe, strict, Python structures. It supports Python 3.6+.
19
-
20
- ### Features
21
-
22
- * Full featured, sophisticated, class-based type system
23
-
24
- * Supports JSON schema draft4 features, including mapping schema-to-code and code-to-schema
25
-
26
- * Serialization, deserialization between JSON-like dict and typedpy objects, including custom mapping. Support for pickling.
27
-
28
- * Easily extensible. [Wrapper of any class as a Field](https://github.com/loyada/typedpy/tree/master/tests/test_typed_field_creator.py)
29
-
30
- * [Inheritance/mixins of fields/classes](https://github.com/loyada/typedpy/tree/master/tests/test_inheritance.py)
31
-
32
- * Embedded structures within structures/fields and fields within fields
33
-
34
- * Supports the common collections
35
-
36
- * [Immutable Structures/Fields](https://github.com/loyada/typedpy/tree/master/tests/test_immutable.py)
37
-
38
- * Clean Java-generics-like definitions, but more flexible. e.g.: Set[AnyOf[Integer(minimum=10), Array]], Map[String(maxLength=8), String]
39
-
40
- * No dependencies on third-party libs
41
-
42
- **There are many examples under "tests/".**
43
-
44
-
45
- #### Documentation
46
-
47
- [Detailed documentation is here](http://typedpy.readthedocs.io)
48
-
49
- #### Installation
50
-
51
- [PyPI page is here](https://pypi.python.org/pypi/typedpy)
52
-
53
- [Conda-Forge page is here](https://anaconda.org/conda-forge/typedpy)
54
-
55
- [travis]:https://travis-ci.org/loyada/typedpy
56
- [travis img]:https://travis-ci.org/loyada/typedpy.svg?branch=master
57
-
58
- [docs img]:https://readthedocs.org/projects/typedpy/badge/?version=latest
59
- [docs]:https://typedpy.readthedocs.io/en/latest/?badge=latest
60
-
61
- [license]:LICENSE.txt
62
- [license img]:https://img.shields.io/badge/License-Apache%202-blue.svg
63
-
64
- [coverage]:https://github.com/loyada/typedpy/blob/master/coverage.txt
65
- [coverage img]:https://raw.githubusercontent.com/loyada/typedpy/master/coverage.svg
66
-
67
- [mutation]:https://github.com/loyada/typedpy/blob/master/mutpy-report.txt
68
- [mutation img]:https://raw.githubusercontent.com/loyada/typedpy/master/mutation-testing.svg
69
-
70
- [pylint img]:https://raw.githubusercontent.com/loyada/typedpy/master/pylint.svg
71
-
72
- [conda-forge]:https://anaconda.org/conda-forge/typedpy/
73
- [conda-forge img]:https://anaconda.org/conda-forge/typedpy/badges/installer/conda.svg
74
-
75
- [pypi]:https://pypi.org/project/typedpy/
76
- [pypi img]:https://img.shields.io/pypi/v/typedpy.svg
typedpy-2.2.0/setup.cfg DELETED
@@ -1,36 +0,0 @@
1
- [metadata]
2
- description-file = README.rst
3
-
4
- [aliases]
5
- test = pytest
6
-
7
- [coverage:run]
8
- branch = True
9
-
10
- [coverage:report]
11
- exclude_lines =
12
- pragma: no cover
13
-
14
- def __repr__
15
- if self\.debug
16
-
17
- raise AssertionError
18
- raise NotImplementedError
19
-
20
- if 0:
21
- if __name__ == .__main__.:
22
- ignore_errors = True
23
-
24
- [coverage:html]
25
- directory = coverage_html_report
26
-
27
- [pylint]
28
- disable = R0903, W0613, C0111, W0703, C0103, W0212
29
- ignore-docstrings = yes
30
- output-format = colorized
31
- fail-under = 9
32
-
33
- [egg_info]
34
- tag_build =
35
- tag_date = 0
36
-
typedpy-2.2.0/setup.py DELETED
@@ -1,43 +0,0 @@
1
- import os
2
-
3
- from setuptools import setup
4
-
5
- with open(os.path.join(os.path.dirname(__file__), "README.md")) as readme:
6
- long_description = readme.read()
7
-
8
- classifiers = [
9
- "Development Status :: 5 - Production/Stable",
10
- "Intended Audience :: Developers",
11
- "License :: OSI Approved :: MIT License",
12
- "Operating System :: OS Independent",
13
- "Programming Language :: Python",
14
- "Programming Language :: Python :: 3.6",
15
- "Programming Language :: Python :: 3.7",
16
- "Programming Language :: Python :: 3.8",
17
- "Programming Language :: Python :: 3.9",
18
- ]
19
-
20
- setup(
21
- name="typedpy",
22
- packages=["typedpy"],
23
- install_requires=[],
24
- author="Danny Loya",
25
- author_email="dan.loya@gmail.com",
26
- classifiers=classifiers,
27
- description="Type-safe Python",
28
- long_description_content_type="text/markdown",
29
- license="MIT",
30
- long_description=long_description,
31
- url="http://github.com/loyada/typedpy",
32
- download_url ="https://github.com/loyada/typedpy/archive/v2.2.0.tar.gz",
33
- keywords=['testing', 'type-safe', 'strict', 'schema', 'validation'],
34
- version='2.2.0'
35
- )
36
-
37
- # coverage run --source=typedpy/ setup.py test
38
- # coverage html
39
- # load in browser from coverage_html_report
40
-
41
- # pylint --rcfile=setup.cfg typedpy
42
- # or
43
- # python3 setup.py lint
@@ -1,98 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: typedpy
3
- Version: 2.2.0
4
- Summary: Type-safe Python
5
- Home-page: http://github.com/loyada/typedpy
6
- Author: Danny Loya
7
- Author-email: dan.loya@gmail.com
8
- License: MIT
9
- Download-URL: https://github.com/loyada/typedpy/archive/v2.2.0.tar.gz
10
- Description: [![][travis img]][travis]
11
- [![][docs img]][docs]
12
-
13
- [![][coverage img]][coverage]
14
- [![][mutation img]][mutation]
15
-
16
- ![pylint img]
17
-
18
-
19
- [![][license img]][license]
20
-
21
- [![][conda-forge img]][conda-forge]
22
- [![][pypi img]][pypi]
23
-
24
-
25
- ## Typedpy - Strict Type System for Python
26
-
27
- ``typedpy`` is a library for type-safe, strict, Python structures. It supports Python 3.6+.
28
-
29
- ### Features
30
-
31
- * Full featured, sophisticated, class-based type system
32
-
33
- * Supports JSON schema draft4 features, including mapping schema-to-code and code-to-schema
34
-
35
- * Serialization, deserialization between JSON-like dict and typedpy objects, including custom mapping. Support for pickling.
36
-
37
- * Easily extensible. [Wrapper of any class as a Field](https://github.com/loyada/typedpy/tree/master/tests/test_typed_field_creator.py)
38
-
39
- * [Inheritance/mixins of fields/classes](https://github.com/loyada/typedpy/tree/master/tests/test_inheritance.py)
40
-
41
- * Embedded structures within structures/fields and fields within fields
42
-
43
- * Supports the common collections
44
-
45
- * [Immutable Structures/Fields](https://github.com/loyada/typedpy/tree/master/tests/test_immutable.py)
46
-
47
- * Clean Java-generics-like definitions, but more flexible. e.g.: Set[AnyOf[Integer(minimum=10), Array]], Map[String(maxLength=8), String]
48
-
49
- * No dependencies on third-party libs
50
-
51
- **There are many examples under "tests/".**
52
-
53
-
54
- #### Documentation
55
-
56
- [Detailed documentation is here](http://typedpy.readthedocs.io)
57
-
58
- #### Installation
59
-
60
- [PyPI page is here](https://pypi.python.org/pypi/typedpy)
61
-
62
- [Conda-Forge page is here](https://anaconda.org/conda-forge/typedpy)
63
-
64
- [travis]:https://travis-ci.org/loyada/typedpy
65
- [travis img]:https://travis-ci.org/loyada/typedpy.svg?branch=master
66
-
67
- [docs img]:https://readthedocs.org/projects/typedpy/badge/?version=latest
68
- [docs]:https://typedpy.readthedocs.io/en/latest/?badge=latest
69
-
70
- [license]:LICENSE.txt
71
- [license img]:https://img.shields.io/badge/License-Apache%202-blue.svg
72
-
73
- [coverage]:https://github.com/loyada/typedpy/blob/master/coverage.txt
74
- [coverage img]:https://raw.githubusercontent.com/loyada/typedpy/master/coverage.svg
75
-
76
- [mutation]:https://github.com/loyada/typedpy/blob/master/mutpy-report.txt
77
- [mutation img]:https://raw.githubusercontent.com/loyada/typedpy/master/mutation-testing.svg
78
-
79
- [pylint img]:https://raw.githubusercontent.com/loyada/typedpy/master/pylint.svg
80
-
81
- [conda-forge]:https://anaconda.org/conda-forge/typedpy/
82
- [conda-forge img]:https://anaconda.org/conda-forge/typedpy/badges/installer/conda.svg
83
-
84
- [pypi]:https://pypi.org/project/typedpy/
85
- [pypi img]:https://img.shields.io/pypi/v/typedpy.svg
86
-
87
- Keywords: testing,type-safe,strict,schema,validation
88
- Platform: UNKNOWN
89
- Classifier: Development Status :: 5 - Production/Stable
90
- Classifier: Intended Audience :: Developers
91
- Classifier: License :: OSI Approved :: MIT License
92
- Classifier: Operating System :: OS Independent
93
- Classifier: Programming Language :: Python
94
- Classifier: Programming Language :: Python :: 3.6
95
- Classifier: Programming Language :: Python :: 3.7
96
- Classifier: Programming Language :: Python :: 3.8
97
- Classifier: Programming Language :: Python :: 3.9
98
- Description-Content-Type: text/markdown