Skip to content

Commit bfdf958

Browse files
authored
Update setup.py for setuptools 69 (#13)
1 parent 8e24eec commit bfdf958

File tree

5 files changed

+36
-46
lines changed

5 files changed

+36
-46
lines changed

parsing/automaton.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def __hash__(self) -> int:
158158
return self._hash
159159

160160
def __eq__(self, other: Any) -> bool:
161-
if type(other) == ItemSet:
161+
if type(other) is ItemSet:
162162
return self._kernel.keys() == other._kernel.keys()
163163
else:
164164
return NotImplemented
@@ -589,7 +589,7 @@ def __repr__(self) -> str:
589589
conflict = "XXX"
590590
break
591591

592-
if type(action) == ShiftAction:
592+
if type(action) is ShiftAction:
593593
lines.append(
594594
"%s %15r : %-6s %d [%s]"
595595
% (
@@ -601,7 +601,7 @@ def __repr__(self) -> str:
601601
)
602602
)
603603
else:
604-
assert type(action) == ReduceAction
604+
assert type(action) is ReduceAction
605605
lines.append(
606606
"%s %15r : %-6s %r"
607607
% (conflict, sym, "reduce", action.production)
@@ -1715,16 +1715,16 @@ def _resolve(
17151715
) -> ConflictResolution:
17161716
ret: ConflictResolution
17171717

1718-
if type(oldAct) == ShiftAction:
1718+
if type(oldAct) is ShiftAction:
17191719
oldPrec = sym.prec
1720-
elif type(oldAct) == ReduceAction:
1720+
elif type(oldAct) is ReduceAction:
17211721
oldPrec = oldAct.production.prec
17221722
else:
17231723
assert False
17241724

1725-
if type(newAct) == ShiftAction:
1725+
if type(newAct) is ShiftAction:
17261726
newPrec = sym.prec
1727-
elif type(newAct) == ReduceAction:
1727+
elif type(newAct) is ReduceAction:
17281728
newPrec = newAct.production.prec
17291729
else:
17301730
assert False
@@ -1740,9 +1740,9 @@ def _resolve(
17401740

17411741
if oldPrec.assoc == "split" or newPrec.assoc == "split":
17421742
ret = "both"
1743-
elif type(newAct) == type(oldAct):
1744-
assert type(newAct) == ReduceAction
1745-
assert type(oldAct) == ReduceAction
1743+
elif type(newAct) is type(oldAct):
1744+
assert type(newAct) is ReduceAction
1745+
assert type(oldAct) is ReduceAction
17461746
# Fatal reduce/reduce conflict.
17471747
ret = "err"
17481748
else:
@@ -1765,16 +1765,16 @@ def _resolve(
17651765
if assoc == "fail":
17661766
ret = "err"
17671767
elif assoc == "left":
1768-
if type(oldAct) == ShiftAction:
1768+
if type(oldAct) is ShiftAction:
17691769
ret = "new"
17701770
else:
1771-
assert type(newAct) == ShiftAction
1771+
assert type(newAct) is ShiftAction
17721772
ret = "old"
17731773
elif assoc == "right":
1774-
if type(oldAct) == ShiftAction:
1774+
if type(oldAct) is ShiftAction:
17751775
ret = "old"
17761776
else:
1777-
assert type(newAct) == ShiftAction
1777+
assert type(newAct) is ShiftAction
17781778
ret = "new"
17791779
elif assoc == "nonassoc":
17801780
ret = "neither"

parsing/glrparser.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def token(self, token: Token) -> None:
127127
tokenSpec = self._spec.sym_spec(token)
128128
self._act(token, tokenSpec) # type: ignore
129129
if len(self._gss) == 0:
130-
raise UnexpectedToken("Unexpected token: %r" % token)
130+
raise UnexpectedToken(f"Unexpected token: {token:r}")
131131

132132
def eoi(self) -> None:
133133
"""
@@ -141,7 +141,7 @@ def eoi(self) -> None:
141141
for path in top.paths():
142142
assert len(path) == 5
143143
if self.verbose:
144-
print(" --> accept %r" % path)
144+
print(f" --> accept {path:r}")
145145
edge = path[1]
146146
assert isinstance(edge, Gsse)
147147
assert isinstance(edge.value, Nonterm)
@@ -181,7 +181,7 @@ def _reductions(self, sym: Token, symSpec: TokenSpec) -> None:
181181
self._gss.pop(i)
182182
else:
183183
for action in self._action[top.nextState][symSpec]:
184-
if type(action) == ReduceAction:
184+
if type(action) is ReduceAction:
185185
if len(action.production.rhs) == 0:
186186
if action.production not in epsilons:
187187
assert (
@@ -324,7 +324,7 @@ def _enqueueLimitedReductions(
324324
for top in self._gss:
325325
if symSpec in self._action[top.nextState]:
326326
for action in self._action[top.nextState][symSpec]:
327-
if type(action) == ReduceAction:
327+
if type(action) is ReduceAction:
328328
if len(action.production.rhs) == 0:
329329
if (
330330
gotos[top.nextState][action.production.lhs]
@@ -377,7 +377,7 @@ def _shifts(self, sym: Token, symSpec: TokenSpec) -> None:
377377
for topA in prevGss:
378378
if symSpec in self._action[topA.nextState]:
379379
for action in self._action[topA.nextState][symSpec]:
380-
if type(action) == ShiftAction:
380+
if type(action) is ShiftAction:
381381
merged = False
382382
for topB in self._gss:
383383
if topB.nextState == topA.nextState:

parsing/lrparser.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Lr(Parser):
2626

2727
def __init__(self, spec: Spec) -> None:
2828
if __debug__:
29-
if type(self) == Lr:
29+
if type(self) is Lr:
3030
assert spec.pureLR
3131
assert spec.conflicts == 0
3232
self._spec = spec
@@ -86,11 +86,11 @@ def _act(self, sym: Token, symSpec: TokenSpec) -> None:
8686

8787
if self.verbose:
8888
print(" --> %r" % action)
89-
if type(action) == ShiftAction:
89+
if type(action) is ShiftAction:
9090
self._stack.append((sym, action.nextState))
9191
break
9292
else:
93-
assert type(action) == ReduceAction
93+
assert type(action) is ReduceAction
9494
self._reduce(action.production)
9595

9696
if self.verbose:

pyproject.toml

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
[project]
22
name = "parsing"
3-
description = "LR(1) parser generator for Python"
3+
description = "LR(1) parser generator for Python and CFSM and GLR parser drivers"
44
requires-python = ">=3.7.0"
5-
dynamic = ["version"]
5+
dynamic = ["version", "dependencies", "optional-dependencies"]
6+
license = { file = "LICENSE" }
7+
authors = [{ name = "Jason Evans", email = "[email protected]" }]
8+
readme = { file = "README.rst", content-type = "text/x-rst" }
9+
classifiers = [
10+
'Development Status :: 5 - Production/Stable',
11+
'Intended Audience :: Developers',
12+
'License :: OSI Approved :: MIT License',
13+
'Operating System :: OS Independent',
14+
'Programming Language :: Python :: 3',
15+
'Topic :: Software Development :: Compilers',
16+
'Topic :: Text Processing :: General',
17+
]
618

719
[build-system]
820
requires = ["setuptools>=42", "wheel"]

setup.py

-22
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
_ROOT = pathlib.Path(__file__).parent
1111

1212

13-
with open(str(_ROOT / "README.rst")) as f:
14-
readme = f.read()
15-
16-
1713
with open(str(_ROOT / "parsing" / "_version.py")) as f:
1814
for line in f:
1915
if line.startswith("__version__ ="):
@@ -88,26 +84,8 @@ def finalize_options(self) -> None:
8884

8985

9086
setup(
91-
name="parsing",
9287
version=VERSION,
9388
python_requires=">=3.7.0",
94-
url="http://www.canonware.com/Parsing/",
95-
license="MIT",
96-
author="Jason Evans",
97-
author_email="[email protected]",
98-
description="A pure-Python module that implements an LR(1) "
99-
"parser generator, as well as CFSM and GLR parser drivers.",
100-
long_description=readme,
101-
long_description_content_type="text/x-rst",
102-
classifiers=[
103-
"Development Status :: 5 - Production/Stable",
104-
"Intended Audience :: Developers",
105-
"License :: OSI Approved :: MIT License",
106-
"Operating System :: OS Independent",
107-
"Programming Language :: Python :: 3",
108-
"Topic :: Software Development :: Compilers",
109-
"Topic :: Text Processing :: General",
110-
],
11189
packages=["parsing", "parsing.tests", "parsing.tests.specs"],
11290
package_data={"parsing": ["py.typed"]},
11391
setup_requires=setup_requires,

0 commit comments

Comments
 (0)