Skip to content

Commit

Permalink
Remove 3.10 dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph-Edwards committed Apr 9, 2024
1 parent dfbf582 commit 4283b4f
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions libsemigroups_pybind11/knuth_bendix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
This package provides the user-facing python part of libsemigroups_pybind11 for
the KnuthBendix class from libsemigroups.
"""
from typing import Union as __Union
from _libsemigroups_pybind11 import (
KnuthBendixRewriteFromLeft as __KnuthBendixRewriteFromLeft,
KnuthBendixRewriteTrie as __KnuthBendixRewriteTrie,
PresentationStrings as __PresentationStrings,
PresentationWords as __PresentationWords,
congruence_kind as __congruence_kind,
KnuthBendixRewriteFromLeft as _KnuthBendixRewriteFromLeft,
KnuthBendixRewriteTrie as _KnuthBendixRewriteTrie,
PresentationStrings as _PresentationStrings,
PresentationWords as _PresentationWords,
congruence_kind as _congruence_kind,
by_overlap_length,
normal_forms,
non_trivial_classes,
Expand All @@ -26,8 +25,8 @@
)


__Presentation = __Union[__PresentationStrings, __PresentationWords]
__KnuthBendix = __Union[__KnuthBendixRewriteFromLeft, __KnuthBendixRewriteTrie]
_Presentation = (_PresentationStrings, _PresentationWords)
_KnuthBendix = (_KnuthBendixRewriteFromLeft, _KnuthBendixRewriteTrie)


def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
Expand All @@ -39,15 +38,15 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
f"KnuthBendix() takes either 1 or 2 positional arguments ({len(args)} given)"
)

if not isinstance(args[0], (__congruence_kind, __KnuthBendix)):
if not isinstance(args[0], (_congruence_kind, _KnuthBendix)):
raise TypeError(
(
f"the first positional argument of KnuthBendix() must either be a congruence_kind"
f"or KnuthBendix instance ({type(args[0])} given)"
)
)

if isinstance(args[0], __KnuthBendix) and len(args) != 1:
if isinstance(args[0], _KnuthBendix) and len(args) != 1:
raise TypeError(
(
f"when copying a KnuthBendix instance, KnuthBendix() must only have one positional"
Expand All @@ -56,7 +55,7 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
)

if (
isinstance(args[0], __KnuthBendixRewriteFromLeft)
isinstance(args[0], _KnuthBendixRewriteFromLeft)
and rewriter != "RewriteFromLeft"
):
raise TypeError(
Expand All @@ -67,7 +66,7 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
)

if (
isinstance(args[0], __KnuthBendixRewriteTrie)
isinstance(args[0], _KnuthBendixRewriteTrie)
and rewriter != "RewriteTrie"
):
raise TypeError(
Expand All @@ -77,7 +76,7 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
)
)

if len(args) == 2 and not isinstance(args[1], __Presentation):
if len(args) == 2 and not isinstance(args[1], _Presentation):
raise TypeError(
(
f"when KnuthBendix() is called with two positional arguments, the second positional"
Expand All @@ -86,9 +85,9 @@ def KnuthBendix(*args, rewriter="RewriteTrie"): # pylint: disable=invalid-name
)

if rewriter == "RewriteFromLeft":
result = __KnuthBendixRewriteFromLeft(*args)
result = _KnuthBendixRewriteFromLeft(*args)
elif rewriter == "RewriteTrie":
result = __KnuthBendixRewriteTrie(*args)
result = _KnuthBendixRewriteTrie(*args)
else:
raise TypeError(
(
Expand Down

0 comments on commit 4283b4f

Please sign in to comment.