diff options
| author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-02-17 23:19:05 +0100 |
|---|---|---|
| committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-02-17 23:51:41 +0100 |
| commit | ea96fc4bce94673671958e15d17bbcd75914b3f9 (patch) | |
| tree | 2c0872b4701f60f2469753f9793f7ac95a0b2475 /astroid/brain | |
| parent | 14395e6e5d9d75b6fe1f87a44b77cfe71a538083 (diff) | |
| download | astroid-git-ea96fc4bce94673671958e15d17bbcd75914b3f9.tar.gz | |
Move from % syntax to format or f-strings
This is possible with python 3.6
Diffstat (limited to 'astroid/brain')
| -rw-r--r-- | astroid/brain/brain_gi.py | 4 | ||||
| -rw-r--r-- | astroid/brain/brain_namedtuple_enum.py | 6 | ||||
| -rw-r--r-- | astroid/brain/brain_six.py | 4 |
3 files changed, 6 insertions, 8 deletions
diff --git a/astroid/brain/brain_gi.py b/astroid/brain/brain_gi.py index f776190d..68f0bbea 100644 --- a/astroid/brain/brain_gi.py +++ b/astroid/brain/brain_gi.py @@ -122,7 +122,7 @@ def _gi_build_stub(parent): strval = str(val) if isinstance(val, str): strval = '"%s"' % str(val).replace("\\", "\\\\") - ret += "%s = %s\n" % (name, strval) + ret += f"{name} = {strval}\n" if ret: ret += "\n\n" @@ -148,7 +148,7 @@ def _gi_build_stub(parent): base = "object" if issubclass(obj, Exception): base = "Exception" - ret += "class %s(%s):\n" % (name, base) + ret += f"class {name}({base}):\n" classret = _gi_build_stub(obj) if not classret: diff --git a/astroid/brain/brain_namedtuple_enum.py b/astroid/brain/brain_namedtuple_enum.py index 042f3d16..9fda8c05 100644 --- a/astroid/brain/brain_namedtuple_enum.py +++ b/astroid/brain/brain_namedtuple_enum.py @@ -182,7 +182,7 @@ def infer_named_tuple(node, context=None): if rename: attributes = _get_renamed_namedtuple_attributes(attributes) - replace_args = ", ".join("{arg}=None".format(arg=arg) for arg in attributes) + replace_args = ", ".join(f"{arg}=None" for arg in attributes) field_def = ( " {name} = property(lambda self: self[{index:d}], " "doc='Alias for field number {index:d}')" @@ -447,9 +447,7 @@ def infer_typing_namedtuple(node, context=None): field_names = "({},)".format(",".join(names)) else: field_names = "''" - node = extract_node( - "namedtuple({typename}, {fields})".format(typename=typename, fields=field_names) - ) + node = extract_node(f"namedtuple({typename}, {field_names})") return infer_named_tuple(node, context) diff --git a/astroid/brain/brain_six.py b/astroid/brain/brain_six.py index c6903282..82d782e1 100644 --- a/astroid/brain/brain_six.py +++ b/astroid/brain/brain_six.py @@ -204,13 +204,13 @@ def _looks_like_nested_from_six_with_metaclass(node): # format when explicit 'six.with_metaclass' is used mod = base.func.expr.name func = base.func.attrname - func = "{}.{}".format(mod, func) + func = f"{mod}.{func}" else: # format when 'with_metaclass' is used directly (local import from six) # check reference module to avoid 'with_metaclass' name clashes mod = base.parent.parent import_from = mod.locals["with_metaclass"][0] - func = "{}.{}".format(import_from.modname, base.func.name) + func = f"{import_from.modname}.{base.func.name}" except (AttributeError, KeyError, IndexError): return False return func == SIX_WITH_METACLASS |
