Skip to content

Commit 135e9cd

Browse files
committed
Fully delinted!
1 parent 9c56960 commit 135e9cd

19 files changed

Lines changed: 62 additions & 57 deletions

‎pylib/__about__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-FileCopyrightText: 2024-present Uche Ogbuji <uche@oori.dev>
22
#
33
# SPDX-License-Identifier: Apache-2.0
4-
__version__ = '4.0.0'
4+
__version__ = '4.0.1'

‎pylib/iri/iri.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def iri_to_uri(iri, convertHost=False):
158158
raise ValueError(_("Illegal surrogate pair in %r" % iri)) # noqa: F821
159159
c = surrogate + c
160160
else:
161-
raise ValueError(_("Illegal surrogate pair in %r" % iri))
161+
raise ValueError(_("Illegal surrogate pair in %r" % iri)) # noqa: F821
162162
surrogate = None
163163
for octet in c.encode('utf-8'):
164164
res += '%%%02X' % ord(octet)

‎pylib/iri/irihelper.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class codex:
5454
'''
5555
Proposed helper IRI stem registry for speeding up IRI comparisons
5656
57-
HOWEVER: Not enough evidence yet of significant enough improvement for the added complexity. Some observations on Python 3.8.5 on MacOS: # noqa: E501
57+
HOWEVER: Not enough evidence yet of significant enough improvement for the added complexity. Some observations on Python 3.8.5 on MacOS:
5858
5959
python -m timeit -s "i1 = 'http://example.org/spam'; i2 = 'http://example.org/eggs';" "i1 == i2; i1 == i1"
6060
@@ -72,7 +72,7 @@ class codex:
7272
7373
Some improvement with an inline prefix to shorten the string, but really worth it?...
7474
75-
'''
75+
''' # noqa: E501
7676
pass
7777

7878

‎pylib/uxml/coax.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ def __init__(self, name, attrmap=None, children=None, ancestor_stack=None):
4545
self.ancestor_stack = ancestor_stack
4646
4747
def unparse(self):
48-
if children:
49-
return '<' + self.name.encode('utf-8') + unparse_attrmap(self.attrmap) + '>' + self.children.unparse() + '</' + self.name.encode('utf-8') + '>' # noqa: E501, F821
48+
if children: # noqa: F821
49+
return ( # noqa: E501, F821
50+
'<' + self.name.encode('utf-8') + unparse_attrmap(self.attrmap) + '>'
51+
+ self.children.unparse() + '</' + self.name.encode('utf-8') + '>'
52+
)
5053
'''
5154

5255

‎pylib/uxml/html5.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,14 @@ def markup_fragment(source, encoding=None):
354354
'''
355355
Parse a fragment of markup in HTML mode, and return a tree node
356356
357-
Warning: if you pass a string, you must make sure it's a byte string, not a Unicode object. You might also want to wrap it with amara.lib.inputsource.text if it's not obviously XML or HTML (for example it could be confused with a file name) # noqa: E501
357+
Warning: if you pass a string, you must make sure it's a byte string, not a Unicode object. You might also want to wrap it with amara.lib.inputsource.text if it's not obviously XML or HTML (for example it could be confused with a file name)
358358
359359
from amara.lib import inputsource
360360
from amara.bindery import html
361-
doc = html.markup_fragment(inputsource.text('XXX<html><body onload="" color="white"><p>Spam!<p>Eggs!</body></html>YYY')) # noqa: E501
361+
doc = html.markup_fragment(inputsource.text('XXX<html><body onload="" color="white"><p>Spam!<p>Eggs!</body></html>YYY'))
362362
363363
See also: http://wiki.xml3k.org/Amara2/Tagsoup [TODO: Page defunct - restore it]
364-
'''
364+
''' # noqa: E501
365365
doc = parse(source, encoding=encoding)
366366
frag = doc.html.body
367367
return frag

‎pylib/uxml/lex.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import ply.lex as lex
1212
from ply.lex import TOKEN
13-
import ply.yacc as yacc
13+
import ply.yacc as yacc # noqa: F401
1414

1515
tokens = (
1616
'NAME','STARTTAG','ENDTAG','GT', 'EQ', 'BOM',
@@ -87,13 +87,13 @@ def t_tag_NAME(t):
8787
return t
8888
#t_NAME.__doc__ = '{0}{1}*'.format(NAMESTARTCHAR, NAMECHAR)
8989

90-
@TOKEN('<{0}*{1}{0}*'.format(WS, NAME_PAT, WS)) # noqa: E501
90+
@TOKEN('<{0}*{1}{0}*'.format(WS, NAME_PAT)) # noqa: E501, F523
9191
def t_data_STARTTAG(t):
9292
t.lexer.begin('tag')
9393
t.value = t.value[1:].strip()
9494
return t
9595

96-
@TOKEN('</{0}*{1}{0}*>'.format(WS, NAME_PAT, WS)) # noqa: E501
96+
@TOKEN('</{0}*{1}{0}*>'.format(WS, NAME_PAT)) # noqa: E501, F523
9797
def t_data_ENDTAG(t):
9898
t.lexer.begin('data')
9999
t.value = t.value[2:-1].strip()

‎pylib/uxml/parser.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def handle_cdata(pos, window, charpat, stopchars):
136136
raise RuntimeError('Unknown named character reference: {0}'.format(repr(window[start:cursor]))) # noqa: E501
137137
break
138138
else:
139-
raise RuntimeError('Illegal in character reference: {0} (around {1})'.format(window[cursor]), error_context(window, start, cursor)) # noqa: E501
139+
raise RuntimeError('Illegal in character reference: {0} (around {1})'.format(window[cursor], error_context(window, start, cursor))) # noqa: E501
140140
#print(start, cursor, cdata, window[cursor])
141141
cursor += 1
142142
start = cursor
@@ -266,7 +266,7 @@ def parser(handler, strict=True):
266266
while NAMECHAR.match(window[advpos]):
267267
advpos += 1
268268
except IndexError:
269-
if not done: need_input = True #Do not advance until we have enough input
269+
if not done: need_input = True # noqa: E701 #Do not advance until we have enough input
270270
pos = backtrackpos
271271
continue
272272
else:
@@ -278,7 +278,7 @@ def parser(handler, strict=True):
278278
while window[pos] in ' \r\n\t':
279279
pos += 1
280280
except IndexError:
281-
if not done: need_input = True #Do not advance until we have enough input
281+
if not done: need_input = True # noqa: E701 #Do not advance until we have enough input
282282
pos = backtrackpos
283283
continue
284284

‎pylib/uxml/tree.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def xml_xpath(self, xpath, vars=None, funcs=None):
6666

6767
class element(node):
6868
'''
69-
Note: Meant to be bare bones & Pythonic. Does no integrity checking of direct manipulations, such as adding an integer to xml_children, or '1' as an attribute name # noqa: E501
70-
'''
69+
Note: Meant to be bare bones & Pythonic. Does no integrity checking of direct manipulations, such as adding an integer to xml_children, or '1' as an attribute name
70+
''' # noqa: E501
7171
def __init__(self, name, attrs=None, parent=None):#, ancestors=None):
7272
node.__init__(self, parent)
7373
self.xml_name = name

‎pylib/uxml/treeutil.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def descendants(elem):
2323
def select_elements(source):
2424
'''
2525
Yields all the elements from the source
26-
source - if an element, yields all child elements in order; if any other iterator yields the elements from that iterator # noqa: E501
27-
'''
26+
source - if an element, yields all child elements in order; if any other iterator yields the elements from that iterator
27+
''' # noqa: E501
2828
if isinstance(source, element): # noqa: F405
2929
source = source.xml_children
3030
return filter(lambda x: isinstance(x, element), source) # noqa: F405
@@ -141,7 +141,7 @@ def _prep_pattern(pattern):
141141
def select_pattern(node, pattern, state=None):
142142
'''
143143
Yield descendant nodes matching the given pattern specification
144-
pattern - tuple of steps, each of which matches an element by name, with "*" acting like a wildcard, descending the tree in tuple order # noqa: E501
144+
pattern - tuple of steps, each of which matches an element by name, with "*" acting like a wildcard, descending the tree in tuple order
145145
sort of like a subset of XPath in Python tuple form
146146
state - for internal use only
147147
@@ -161,7 +161,7 @@ def select_pattern(node, pattern, state=None):
161161
>>> results = [ e.xml_value for e in select_pattern(root, ('**', 'x')) ]
162162
>>> results
163163
['1', '2', '3', '4']
164-
'''
164+
''' # noqa: E501
165165
if state is None:
166166
state = _prep_pattern(pattern)
167167
#for child in select_elements(elem):
@@ -201,8 +201,8 @@ def make_pretty(elem, depth=0, indent=' '):
201201
>>> len(root.xml_children)
202202
9
203203
>>> root.xml_encode()
204-
'<a>\n <b>\n <x>1</x>\n </b>\n <c>\n <x>2</x>\n <d>\n <x>3</x>\n </d>\n </c>\n <x>4</x>\n <y>5</y>\n</a>' # noqa: E501
205-
'''
204+
'<a>\n <b>\n <x>1</x>\n </b>\n <c>\n <x>2</x>\n <d>\n <x>3</x>\n </d>\n </c>\n <x>4</x>\n <y>5</y>\n</a>'
205+
''' # noqa: E501
206206
depth += 1
207207
updated_child_list = []
208208
updated_child_ix = 0

‎pylib/uxml/writer.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from enum import Enum #https://docs.python.org/3.4/library/enum.html
77
from xml.sax.saxutils import escape, quoteattr
88

9-
from amara.uxml import tree, xml
9+
from amara.uxml import tree, xml # noqa: F401
1010

1111
class token(Enum):
1212
start_open = 1
@@ -68,7 +68,7 @@ def write(self, ctx, text):
6868
# if ctx in (context.text, context.attribute_text):
6969
if ctx in (context.text,):
7070
text = escape(text)
71-
if isinstance(text, token): text = TOKENS[text]
71+
if isinstance(text, token): text = TOKENS[text] # noqa: E701
7272
self._fp.write(text)
7373
return
7474

@@ -176,7 +176,7 @@ def write(self, ctx, text):
176176
prefix = self._mapping.get('@' + text, ('', ''))[1]
177177
if prefix:
178178
self._fp.write(prefix + ':')
179-
if isinstance(text, token): text = TOKENS[text]
179+
if isinstance(text, token): text = TOKENS[text] # noqa: E701
180180
self._fp.write(text)
181181
return
182182

0 commit comments

Comments
 (0)