diff options
| author | nicholascar <nicholas.car@surroundaustralia.com> | 2021-12-07 16:20:26 +1000 |
|---|---|---|
| committer | nicholascar <nicholas.car@surroundaustralia.com> | 2021-12-07 16:20:26 +1000 |
| commit | 15dec4abd49c110ad5249ddf0668a72afd2cd6b4 (patch) | |
| tree | f1c46ff4bf2aacf0bc2a4bb7e2ccbcc8ba8e4698 | |
| parent | 75b797e0aacdd098d5ad7c863fc628d468f4dfe9 (diff) | |
| download | rdflib-15dec4abd49c110ad5249ddf0668a72afd2cd6b4.tar.gz | |
Flake8 style improvements
| -rw-r--r-- | rdflib/namespace/__init__.py | 7 | ||||
| -rwxr-xr-x | rdflib/plugins/parsers/notation3.py | 36 | ||||
| -rw-r--r-- | rdflib/plugins/parsers/ntriples.py | 6 | ||||
| -rw-r--r-- | rdflib/plugins/parsers/trig.py | 6 |
4 files changed, 27 insertions, 28 deletions
diff --git a/rdflib/namespace/__init__.py b/rdflib/namespace/__init__.py index 0487a55d..68bc1726 100644 --- a/rdflib/namespace/__init__.py +++ b/rdflib/namespace/__init__.py @@ -81,7 +81,6 @@ The following namespaces are available by directly importing from rdflib: __all__ = ["is_ncname", "split_uri", "Namespace", "ClosedNamespace", "NamespaceManager"] - logger = logging.getLogger(__name__) @@ -192,7 +191,7 @@ class DefinedNamespaceMeta(type): name = str(name) if str(name).startswith("__"): return super().__getitem__(name, default) - if (cls._warn or cls._fail) and not name in cls: + if (cls._warn or cls._fail) and name not in cls: if cls._fail: raise AttributeError(f"term '{name}' not in namespace '{cls._NS}'") else: @@ -220,7 +219,7 @@ class DefinedNamespaceMeta(type): if item_str.startswith("__"): return super().__contains__(item) if item_str.startswith(str(cls._NS)): - item_str = item_str[len(str(cls._NS)) :] + item_str = item_str[len(str(cls._NS)):] return any( item_str in c.__annotations__ or item_str in c._extras @@ -419,7 +418,7 @@ class NamespaceManager(object): pl_namespace = get_longest_namespace(self.__strie[namespace], uri) if pl_namespace is not None: namespace = pl_namespace - name = uri[len(namespace) :] + name = uri[len(namespace):] namespace = URIRef(namespace) prefix = self.store.prefix(namespace) # warning multiple prefixes problem diff --git a/rdflib/plugins/parsers/notation3.py b/rdflib/plugins/parsers/notation3.py index cfdc8568..df2e8758 100755 --- a/rdflib/plugins/parsers/notation3.py +++ b/rdflib/plugins/parsers/notation3.py @@ -143,7 +143,7 @@ def join(here, there): "colon - with relative '%s'." % (here, there) ) - if here[bcolonl + 1 : bcolonl + 3] == "//": + if here[bcolonl + 1: bcolonl + 3] == "//": bpath = here.find("/", bcolonl + 3) else: bpath = bcolonl + 1 @@ -530,7 +530,7 @@ class SinkParser: assert tok[0] not in _notNameChars # not for punctuation len_tok = len(tok) - if argstr[i : i + len_tok].lower() == tok.lower() and ( + if argstr[i: i + len_tok].lower() == tok.lower() and ( argstr[i + len_tok] in _notQNameChars ): i += len_tok @@ -798,7 +798,7 @@ class SinkParser: res.append(("->", RDF_type)) return j - if argstr[i : i + 2] == "<=": + if argstr[i: i + 2] == "<=": if self.turtle: self.BadSyntax(argstr, i, "Found '<=' in Turtle mode. ") @@ -814,7 +814,7 @@ class SinkParser: res.append(("->", DAML_sameAs)) return i + 1 - if argstr[i : i + 2] == ":=": + if argstr[i: i + 2] == ":=": if self.turtle: self.BadSyntax(argstr, i, "Found ':=' in Turtle mode") @@ -827,7 +827,7 @@ class SinkParser: res.append(("->", r[0])) return j - if argstr[i : i + 2] == ">-" or argstr[i : i + 2] == "<-": + if argstr[i: i + 2] == ">-" or argstr[i: i + 2] == "<-": self.BadSyntax(argstr, j, ">- ... -> syntax is obsolete.") return -1 @@ -945,7 +945,7 @@ class SinkParser: i = self.skipSpace(argstr, j) if i < 0: self.BadSyntax(argstr, i, "needed '$}', found end.") - if argstr[i : i + 2] == "$}": + if argstr[i: i + 2] == "$}": j = i + 2 break @@ -1068,7 +1068,7 @@ class SinkParser: break i = j + 1 - if argstr[j : j + 2] == ":-": + if argstr[j: j + 2] == ":-": if self.turtle: self.BadSyntax(argstr, j, "Found in ':-' in Turtle mode") i = j + 2 @@ -1428,7 +1428,7 @@ class SinkParser: ch = argstr[i] if ch in self.string_delimiters: ch_three = ch * 3 - if argstr[i : i + 3] == ch_three: + if argstr[i: i + 3] == ch_three: delim = ch_three i += 3 else: @@ -1478,7 +1478,7 @@ class SinkParser: ch_three = ch * 3 if ch in self.string_delimiters: - if argstr[i : i + 3] == ch_three: + if argstr[i: i + 3] == ch_three: delim = ch_three i += 3 else: @@ -1499,9 +1499,9 @@ class SinkParser: "Bad language code syntax on string " + "literal, after @", ) i = m.end() - lang = argstr[j + 1 : i] + lang = argstr[j + 1: i] j = i - if argstr[j : j + 2] == "^^": + if argstr[j: j + 2] == "^^": res2 = [] j = self.uri_ref2(argstr, j + 2, res2) # Read datatype URI dt = res2[0] @@ -1535,15 +1535,15 @@ class SinkParser: if ( delim == delim3 ): # done when delim is """ or ''' and, respectively ... - if argstr[j : j + 5] == delim5: # ... we have "" or '' before + if argstr[j: j + 5] == delim5: # ... we have "" or '' before i = j + 5 ustr += delim2 return i, ustr - if argstr[j : j + 4] == delim4: # ... we have " or ' before + if argstr[j: j + 4] == delim4: # ... we have " or ' before i = j + 4 ustr += delim1 return i, ustr - if argstr[j : j + 3] == delim3: # current " or ' is part of delim + if argstr[j: j + 3] == delim3: # current " or ' is part of delim i = j + 3 return i, ustr @@ -1555,8 +1555,8 @@ class SinkParser: m = interesting.search(argstr, j) # was argstr[j:]. # Note for pos param to work, MUST be compiled ... re bug? assert m, "Quote expected in string at ^ in %s^%s" % ( - argstr[j - 20 : j], - argstr[j : j + 20], + argstr[j - 20: j], + argstr[j: j + 20], ) # at least need a quote i = m.start() @@ -1633,7 +1633,7 @@ class SinkParser: self._thisDoc, startline, argstr, i, "unterminated string literal(3)" ) try: - return i + n, reg.sub(unicodeExpand, "\\" + prefix + argstr[i : i + n]) + return i + n, reg.sub(unicodeExpand, "\\" + prefix + argstr[i: i + n]) except: raise BadSyntax( self._thisDoc, @@ -1685,7 +1685,7 @@ class BadSyntax(SyntaxError): self._why, pre, argstr[st:i], - argstr[i : i + 60], + argstr[i: i + 60], post, ) diff --git a/rdflib/plugins/parsers/ntriples.py b/rdflib/plugins/parsers/ntriples.py index a86bd66f..a5858bc2 100644 --- a/rdflib/plugins/parsers/ntriples.py +++ b/rdflib/plugins/parsers/ntriples.py @@ -65,7 +65,7 @@ def unquote(s): while s: m = r_safe.match(s) if m: - s = s[m.end() :] + s = s[m.end():] result.append(m.group(1)) continue @@ -77,7 +77,7 @@ def unquote(s): m = r_uniquot.match(s) if m: - s = s[m.end() :] + s = s[m.end():] u, U = m.groups() codepoint = int(u or U, 16) if codepoint > 0x10FFFF: @@ -224,7 +224,7 @@ class W3CNTriplesParser(object): # print(dir(pattern)) # print repr(self.line), type(self.line) raise ParseError("Failed to eat %s at %s" % (pattern.pattern, self.line)) - self.line = self.line[m.end() :] + self.line = self.line[m.end():] return m def subject(self, bnode_context=None): diff --git a/rdflib/plugins/parsers/trig.py b/rdflib/plugins/parsers/trig.py index 9caa0662..1addb747 100644 --- a/rdflib/plugins/parsers/trig.py +++ b/rdflib/plugins/parsers/trig.py @@ -80,7 +80,7 @@ class TrigSinkParser(SinkParser): if j < 0: self.BadSyntax(argstr, i, "EOF found when expected graph") - if argstr[j : j + 1] == "=": # optional = for legacy support + if argstr[j: j + 1] == "=": # optional = for legacy support i = self.skipSpace(argstr, j + 1) if i < 0: @@ -88,7 +88,7 @@ class TrigSinkParser(SinkParser): else: i = j - if argstr[i : i + 1] != "{": + if argstr[i: i + 1] != "{": return -1 # the node wasn't part of a graph j = i + 1 @@ -104,7 +104,7 @@ class TrigSinkParser(SinkParser): if i < 0: self.BadSyntax(argstr, i, "needed '}', found end.") - if argstr[i : i + 1] == "}": + if argstr[i: i + 1] == "}": j = i + 1 break |
