Skip to content

Commit 9d576c8

Browse files
committed
🎨 Migrate to Pytest
1 parent 5971827 commit 9d576c8

37 files changed

+1347
-1419
lines changed

Diff for: pyformlang/cfg/cfg.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" A context free grammar """
22
import string
33
from copy import deepcopy
4-
from typing import AbstractSet, Iterable, Tuple, Dict, Any
4+
from typing import AbstractSet, Iterable, Tuple, Dict, Any, Union
55

66
import networkx as nx
77

@@ -56,9 +56,9 @@ class CFG:
5656
# pylint: disable=too-many-instance-attributes
5757

5858
def __init__(self,
59-
variables: AbstractSet[Variable] = None,
60-
terminals: AbstractSet[Terminal] = None,
61-
start_symbol: Variable = None,
59+
variables: AbstractSet[Union[Variable, str]] = None,
60+
terminals: AbstractSet[Union[Terminal, str]] = None,
61+
start_symbol: Union[Variable, str] = None,
6262
productions: Iterable[Production] = None):
6363
if variables is not None:
6464
variables = {to_variable(x) for x in variables}
@@ -706,10 +706,10 @@ def is_empty(self) -> bool:
706706
def __bool__(self):
707707
return not self.is_empty()
708708

709-
def __contains__(self, word: Iterable[Terminal]) -> bool:
709+
def __contains__(self, word: Iterable[Union[Terminal, str]]) -> bool:
710710
return self.contains(word)
711711

712-
def contains(self, word: Iterable[Terminal]) -> bool:
712+
def contains(self, word: Iterable[Union[Terminal, str]]) -> bool:
713713
""" Gives the membership of a word to the grammar
714714
715715
Parameters

Diff for: pyformlang/cfg/cyk_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CYKTable:
1212
Parameters
1313
----------
1414
cfg : A context-free grammar
15-
word : tuple of Terminals
15+
word : iterable of Terminals
1616
The word from which we construct the CYK table
1717
"""
1818

Diff for: pyformlang/cfg/terminal.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@
44

55

66
class Terminal(CFGObject): # pylint: disable=too-few-public-methods
7-
""" An terminal in a CFG
8-
9-
Parameters
10-
-----------
11-
value : any
12-
The value of the terminal
13-
"""
7+
""" A terminal in a CFG """
148

159
def __eq__(self, other):
1610
return isinstance(other, Terminal) and self.value == other.value

0 commit comments

Comments
 (0)