From 484c6e97f1d62e99b82c63823ad37814afb1b466 Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Tue, 11 Jun 2019 18:33:07 +0200 Subject: [PATCH] Support Python 3.6 --- .travis.yml | 1 + README.md | 2 +- nnf/__init__.py | 22 ++++++++++------------ setup.py | 3 ++- tox.ini | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8852eb7..5559f51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ dist: xenial language: python python: + - "3.6" - "3.7" install: diff --git a/README.md b/README.md index fd75e9a..46cd708 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ This package takes much of its data model and terminology from pip install nnf ``` -Only Python 3.7 or higher is currently supported. +At least Python 3.6 is required. # Serialization diff --git a/nnf/__init__.py b/nnf/__init__.py index 78b16d5..e42c669 100644 --- a/nnf/__init__.py +++ b/nnf/__init__.py @@ -12,8 +12,6 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -from __future__ import annotations - import functools import itertools import typing as t @@ -57,15 +55,15 @@ def all_models(names: t.Collection[Name]) -> t.Iterator[Model]: class NNF: """Base class for all NNF sentences.""" - def __and__(self, other: NNF) -> NNF: + def __and__(self, other: 'NNF') -> 'NNF': """And({self, other})""" return And({self, other}) - def __or__(self, other: NNF) -> NNF: + def __or__(self, other: 'NNF') -> 'NNF': """Or({self, other})""" return Or({self, other}) - def walk(self) -> t.Iterator[NNF]: + def walk(self) -> t.Iterator['NNF']: """Yield all nodes in the sentence, depth-first. Nodes that appear multiple times are yielded only once. @@ -256,7 +254,7 @@ def models(self, decomposable: _Tristate = None) -> t.Iterator[Model]: if self.satisfied_by(model): yield model - def contradicts(self, other: NNF) -> bool: + def contradicts(self, other: 'NNF') -> bool: """There is no set of values that satisfies both sentences.""" if self.vars() != other.vars(): raise ValueError("Sentences mention different variables") @@ -267,7 +265,7 @@ def contradicts(self, other: NNF) -> bool: return False return True - def to_MODS(self) -> NNF: + def to_MODS(self) -> 'NNF': """Convert the sentence to a MODS sentence.""" return Or(And(Var(name, val) for name, val in model.items()) @@ -295,7 +293,7 @@ def to_model(self) -> Model: return model - def condition(self, model: Model) -> NNF: + def condition(self, model: Model) -> 'NNF': """Fill in all the values in the dictionary.""" @memoize def cond(node: NNF) -> NNF: @@ -315,7 +313,7 @@ def cond(node: NNF) -> NNF: return cond(self) - def simplify(self) -> NNF: + def simplify(self) -> 'NNF': """Apply the following transformations to make the sentence simpler: - If an And node has `false` as a child, replace it by `false` @@ -367,7 +365,7 @@ def simple(node: NNF) -> NNF: return simple(self) - def deduplicate(self) -> NNF: + def deduplicate(self) -> 'NNF': """Return a copy of the sentence without any duplicate objects. If a node has multiple parents, it's possible for it to be @@ -464,7 +462,7 @@ def name(node: NNF) -> int: def transform( self, - func: t.Callable[[t.Callable[[NNF], T], NNF], T] + func: t.Callable[[t.Callable[['NNF'], T], 'NNF'], T] ) -> T: """A helper function to apply a transformation with memoization. @@ -625,7 +623,7 @@ def __repr__(self) -> str: base = f"{self.__class__.__name__}({self.name!r})" return base if self.true else f"~{base}" - def __invert__(self) -> Var: + def __invert__(self) -> 'Var': return Var(self.name, not self.true) diff --git a/setup.py b/setup.py index f635ae0..ffd0804 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="nnf", - version="0.0.2", + version="0.0.3", author="Jan Verbeek", author_email="jan.verbeek@posteo.nl", description="Manipulate NNF (Negation Normal Form) logical sentences", @@ -21,6 +21,7 @@ "Development Status :: 2 - Pre-Alpha", "Programming Language :: Python", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "License :: OSI Approved :: ISC License (ISCL)", diff --git a/tox.ini b/tox.ini index b035ed1..809706c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37 +envlist = py36, py37 [testenv] deps =