Skip to content

Commit

Permalink
remove f-string for 3.4 and 3.5 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Aluriak committed Nov 19, 2019
1 parent fe9b5c1 commit 80245b2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ the official module can be used by clyngor if it is available.
- 0.4.0 (todo)
- see [further ideas](#Further-ideas)
- 0.3.25
- [a7b05ecdb](https://github.com/aluriak/clyngor/commit/a7b05ecdbd5f73dbee5a7244a96995d9035f3695): remove f-strings for 3.4 and 3.5 compat.
- [6efdb6ab0](https://github.com/aluriak/clyngor/commit/6efdb6ab0f0304b28b35d6ceb16545226b2f9e3e): fix combination of .as_pyasp and .parse_args, where atoms in args were not transformed as pyasp Atom objects.
- [fe4107573](https://github.com/aluriak/clyngor/commit/fe410757386e2c3e0881ecc90d7f18ee97672194): correctly parse atoms starting with underscores.
- [d6507f17d](https://github.com/aluriak/clyngor/commit/d6507f17dbf27c6c309e3e4009a234b9d63134ba): careful parsing is automatically set when answer set [obviously needs it](clyngor/parsing.py#L266).
Expand Down
2 changes: 1 addition & 1 deletion clyngor/answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _parse_answer(self, answer_set:str) -> iter:
answer_set = utils.integers_to_string_atoms(answer_set)
yield from self.__finish_parsing(answer_set)
else: # unknown format
raise ValueError(f"unknow answer set format: {type(answer_set)}, {answer_set}")
raise ValueError("unknow answer set format: {}, {}".format(type(answer_set), answer_set))

def __finish_parsing(self, answer_set:[(str, tuple)]) -> [(str, tuple) or str]:
"""Modify (pred, args) atoms according to parsing options"""
Expand Down
4 changes: 2 additions & 2 deletions clyngor/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def objects_from_model(decoder:type, model:dict):
@lru_cache(maxsize=32)
def object_builder_from_decoder(decoder:type) -> dict:
if not hasattr(decoder, '__init__'):
raise ValueError(f"Decoder {decoder} has no __init__ method")
raise ValueError("Decoder {} has no __init__ method".format(decoder))
constructor = decoder.__init__
sig = signature(constructor)
params = iter(sig.parameters.items())
Expand All @@ -49,7 +49,7 @@ def object_builder_from_decoder(decoder:type) -> dict:
elif anno == 1: # one for each atom
atoms_each.add(name)
else:
raise ValueError(f"Decoder can't handle the annotation '{anno}'")
raise ValueError("Decoder can't handle the annotation '{}'".format(anno))
return {
'all': frozenset(atoms_all),
'foreach': frozenset(atoms_each),
Expand Down
2 changes: 1 addition & 1 deletion clyngor/test/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __eq__(self, othr):
def __hash__(self): # ensure equivalence in set
return hash(tuple(map(hash, (self.id, self.extent, self.intent))))
def __repr__(self): # help for debug
return f"<{self.id}: {{{','.join(sorted(self.extent))}}} × {{{','.join(sorted(self.intent))}}}>"
return "<{}: {{{}}} × {{{}}}>".format(self.id, ','.join(sorted(self.extent)), ','.join(sorted(self.intent)))
@staticmethod
def expected():
return {
Expand Down
2 changes: 1 addition & 1 deletion clyngor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def python_value_to_asp(val:str or int or list or tuple, *, args_of_predicate:bo
elif isinstance(val, list):
ender = ',' if len(val) == 1 and not args_of_predicate else ''
return ','.join(map(python_value_to_asp, val)) + ender
raise ValueError(f"Python value '{repr(val)}' of type {type(val)} is not convertible in ASP.")
raise ValueError("Python value '{}' of type {} is not convertible in ASP.".format(repr(val), type(val)))
# python_value_to_asp.in_predicate = lambda x: python_value_to_asp(x, args_of_predicate=True)


Expand Down

0 comments on commit 80245b2

Please sign in to comment.