Skip to content

Commit

Permalink
1.1.1 - Fix errors for python<3.10. Lock python>=3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-makowski committed Nov 17, 2023
1 parent cfadebd commit b58d79f
Show file tree
Hide file tree
Showing 8 changed files with 541 additions and 516 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ A pure python (no special compiler required) type enforcer for type annotations.

# Setup

Make sure you have Python 3.7.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).
Make sure you have Python 3.9.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/). For older python versions (3.7 | 3.8), you should use type_enforced==0.0.16.

- Note: Certain features are only available on newer python versions
- Note: Certain features are only available on newer python versions:
- EG: Staticmethod typechecking requires `python>=3.10`
- EG: Union types with `|` require `python>=3.10`

### Installation

Expand Down
Binary file added dist/type_enforced-1.1.1-py3-none-any.whl
Binary file not shown.
Binary file added dist/type_enforced-1.1.1.tar.gz
Binary file not shown.
1,029 changes: 519 additions & 510 deletions docs/type_enforced/enforcer.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "type_enforced"
version = "1.1.0"
version = "1.1.1"
description = "A pure python type enforcer for python type annotations"
authors = [
{name="Connor Makowski", email="[email protected]"}
]
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
'License :: OSI Approved :: MIT License',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = type_enfoced
version = 1.1.0
version = 1.1.1
description_file = README.md

[options]
Expand Down
6 changes: 6 additions & 0 deletions test/test_fn_10.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type_enforced
from typing import Union
import sys

# Test | only if python version >= 3.10
if sys.version_info < (3, 10):
print("test_fn_10.py skipped")
exit()


@type_enforced.Enforcer
Expand Down
11 changes: 10 additions & 1 deletion type_enforced/enforcer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
from types import FunctionType, MethodType, GenericAlias, UnionType
from types import FunctionType, MethodType, GenericAlias
from typing import Type, Union, Sized
from functools import update_wrapper, wraps

# Python 3.10+ has a UnionType object that is used to represent Union types
try:
from types import UnionType
except ImportError:
# Python < 3.10 does not have UnionType
# Since UnionType is validated after NoneType, we can use NoneType
# as a stand in for UnionType to ignore it in older versions of python
UnionType = type(None)


class FunctionMethodEnforcer:
def __init__(self, __fn__):
Expand Down

0 comments on commit b58d79f

Please sign in to comment.