1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
Description: drop obsolete dependency on async-generators
This has not been necessary since python 3.11.
The author has been contacted directly.
Forwarded: yes
Author: Nicolas Boulenguez <nicolas@debian.org>
--- a/doc/source/parser.rst
+++ b/doc/source/parser.rst
@@ -301,10 +301,7 @@
=========================
The :py:class:`AsyncLexer` and :py:class:`AsyncLRParser` classes allow
-you to parse an input stream asynchronously. Since this uses the new
-asynchronous method syntax introduced in Python 3.5, it's only
-available with this version of Python. Additionally, you must install
-the `async_generator <https://github.com/python-trio/async_generator>`_ module.
+you to parse an input stream asynchronously.
The basic idea is that the production methods are asynchronous. Feed
the input stream one byte/char at a time by awaiting on
--- a/ptk/async_lexer.py
+++ b/ptk/async_lexer.py
@@ -3,18 +3,12 @@
# (c) Jérôme Laheurte 2015-2019
# See LICENSE.txt
-# XXXTODO: when pylint supports async, remove this...
-# pylint: skip-file
+from contextlib import aclosing
from ptk.lexer import ProgressiveLexer, token, EOF, LexerError
from ptk.regex import DeadState
from ptk.utils import chars
-try:
- from async_generator import aclosing, async_generator, yield_, yield_from_
-except ImportError:
- raise RuntimeError('You need to have the async_generator package installed to use the async lexer.')
-
class AsyncLexer(ProgressiveLexer):
"""
@@ -45,7 +39,6 @@
if value is not None:
return value
- @async_generator
async def asyncIterFeed(self, char, charPos=None):
self._input.append((char, charPos))
while self._input:
@@ -54,13 +47,13 @@
async for tok in agen:
value = await self.asyncNewToken(tok)
if value is not None:
- await yield_(value)
+ yield value
- @async_generator
async def asyncIterParse(self, chars):
for char in chars:
async with aclosing(self.asyncIterFeed(char)) as agen:
- await yield_from_(agen)
+ async for x in agen:
+ yield x
async def asyncNewToken(self, tok):
"""
@@ -68,7 +61,6 @@
"""
raise NotImplementedError
- @async_generator
async def _asyncFeed(self, char, charPos): # pylint: disable=R0912,R0915
# Unfortunately this is copy/pasted from ProgressiveLexer._feed to add the async stuff...
if char in chars('\n'):
@@ -81,14 +73,14 @@
if tok is not None:
self.setConsumer(None)
if tok[0] is not None:
- await yield_(self.Token(*tok, self.position()))
+ yield self.Token(*tok, self.position())
return
try:
if char is EOF:
if self._state == 0:
self.restartLexer()
- await yield_(EOF)
+ yield EOF
return
self._maxPos = max(self._maxPos, max(pos[0] for regex, callback, defaultType, pos in self._currentState))
if self._maxPos == 0 and self._currentMatch:
@@ -133,8 +125,8 @@
tok = self._finalizeMatch()
if tok is not None:
- await yield_(tok)
+ yield tok
if char is EOF:
self.restartLexer()
- await yield_(EOF)
+ yield EOF
--- a/ptk/async_parser.py
+++ b/ptk/async_parser.py
@@ -3,9 +3,6 @@
# (c) Jérôme Laheurte 2015-2019
# See LICENSE.txt
-# XXXTODO: when pylint supports async, remove this...
-# pylint: skip-file
-
from ptk.parser import production, LRParser, ProductionParser, leftAssoc, rightAssoc, nonAssoc, ParseError, _Accept, _Reduce, _Shift
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,3 @@
sphinx
-async_generator
coverage
pylint
|