flake8配置_errorflashdownloadfailed-could

flake8配置_errorflashdownloadfailed-couldflake8错误码

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

flake8 错误修复指南

B开头的错误

flake8-bugbear是一个用于查找程序中可能存在的 bug 和设计问题的插件,错误码以B开头

B001: Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you’re sure what you’re doing, be explicit and write except BaseException:. Disable E722 to avoid duplicate warnings.

B001: 不要使用 bare except: ,它还可以捕获内存错误、中断、系统出口等意外事件。除了例外: 。如果你确定你正在做什么,那么明确的写除了 BaseException: 。禁用 e722以避免重复警告。

B002: Python does not support the unary prefix increment. Writing ++n is equivalent to +(+(n)), which equals n. You meant n += 1.

B002: Python 不支持一元前缀递增。写 + + n 等于 + (+ (n)) ,它等于 n。你的意思是 n + = 1。

B003: Assigning to os.environ doesn’t clear the environment. Subprocesses are going to see outdated variables, in disagreement with the current process. Use os.environ.clear() or the env= argument to Popen.

B003: 将任务分配给 os.environ 并不能清除环境。子流程将看到过时的变量,与当前流程不一致。对 Popen 使用 os.environment.clear ()或 env = 参数。

B004: Using hasattr(x, ‘call’) to test if x is callable is unreliable. If x implements custom getattr or its call is itself not callable, you might get misleading results. Use callable(x) for consistent results.

B004: 使用 hasattr (x,’_ call _’)来测试 x 是否可调用是不可靠的。如果 x 实现了自定义 getattr 或者它的调用本身不可调用,你可能会得到错误的结果。使用可调用(x)以获得一致的结果。

B005: Using .strip() with multi-character strings is misleading the reader. It looks like stripping a substring. Move your character set to a constant if this is deliberate. Use .replace() or regular expressions to remove string fragments.

B005: 使用。带有多个字符串的 strip ()会误导读者。它看起来像剥离子字符串。如果是故意的,则将角色设置为常量。使用。Replace ()或正则表达式来删除字符串片段。

B006: Do not use mutable data structures for argument defaults. They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.

B006: 不要对参数默认值使用可变数据结构。它们是在函数定义时创建的。对该函数的所有调用都重用该数据结构的这个实例,并在它们之间持久化更改。

B007: Loop control variable not used within the loop body. If this is intended, start the name with an underscore.

B007: 循环控制变量不在循环体中使用,如果是这样的话,用下划线开始命名。

B008: Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.

B008: 在参数默认情况下不执行函数调用。在函数定义时只执行一次调用。对函数的所有调用都将重用定义时函数调用的结果。如果这是有意为之,那么将函数调用分配给模块级变量,并将该变量用作默认值。

B009: Do not call getattr(x, ‘attr’), instead use normal property access: x.attr. Missing a default to getattr will cause an AttributeError to be raised for non-existent properties. There is no additional safety in using getattr if you know the attribute name ahead of time.

B009: 不要调用 getattr (x,‘ attr’) ,而是使用 normal property access: x.attr。缺少 getattr 的默认值将导致为不存在的属性引发 AttributeError。如果您事先知道属性名称,那么使用 getattr 就没有额外的安全性。

B010: Do not call setattr(x, ‘attr’, val), instead use normal property access: x.attr = val. There is no additional safety in using setattr if you know the attribute name ahead of time.

B010: 不要调用 setattr (x,‘ attr’,val) ,而是使用 normal property access: x.attr = val。如果您事先知道属性名称,那么使用 setattr 就没有额外的安全性。

B011: Do not call assert False since python -O removes these calls. Instead callers should raise AssertionError().

B011: 不要调用 assert False,因为 python-o 会删除这些调用。相反,调用者应该引发 AssertionError ()。

B012: Use of break, continue or return inside finally blocks will silence exceptions or override return values from the try or except blocks. To silence an exception, do it explicitly in the except block. To properly use a break, continue or return refactor your code so these statements are not in the finally block.

B012: 使用 break、 continue 或 return inside finally block will silence exceptions or override return value from the try or except blocks。为了使异常无声,请在 except 块中显式执行此操作。若要正确使用中断,请继续或返回重构代码,使这些语句不在 finally 块中。

B013: A length-one tuple literal is redundant. Write except SomeError: instead of except (SomeError,):.

B013: length-one tuple literal 是冗余的。

B014: Redundant exception types in except (Exception, TypeError):. Write except Exception:, which catches exactly the same exceptions.

B014: Redundant Exception types in except (Exception,TypeError) : . Write except: ,它捕获完全相同的异常。

B015: Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend assert or remove it.

B015: 无意义的比较。这种比较只会浪费 CPU 指令。要么补充断言,要么删除它。

B016: Cannot raise a literal. Did you intend to return it or raise an Exception?

不能提升一个字面值。你是打算返回它还是提升一个例外值?

B017: self.assertRaises(Exception): should be considered evil. It can lead to your test passing even if the code being tested is never executed due to a typo. Either assert for a more specific exception (builtin or custom), use assertRaisesRegex, or use the context manager form of assertRaises (with self.assertRaises(Exception) as ex:) with an assertion against the data available in ex.

B017: self.assertRaises (例外) : 应被视为邪恶。它可以导致您的测试通过,即使正在测试的代码由于输入错误而从未执行。要么为更特定的异常(内建的或定制的)断言,使用 assertRaisesRegex,要么使用 assertRaises 的上下文管理器形式(使用 self.assertRaises (Exception)作为 ex:) ,对 ex 中可用的数据进行断言。

B018: Found useless expression. Either assign it to a variable or remove it.

B018: 找到无用的表达式。要么将其赋值给变量,要么将其删除。

B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks. The cache may retain instance references, preventing garbage collection.

B019: 在方法上使用 functools.lru 缓存或 functools.cache 会导致内存泄漏。缓存可能保留实例引用,防止垃圾回收。

B020: Loop control variable overrides iterable it iterates

020: 循环/控制变量/代码重写迭代

B021: f-string used as docstring. This will be interpreted by python as a joined string rather than a docstring.

B021: f-string 用作文档字符串。这将被 python 解释为一个连接字符串,而不是文档字符串。

B022: No arguments passed to contextlib.suppress. No exceptions will be suppressed and therefore this context manager is redundant. N.B. this rule currently does not flag suppress calls to avoid potential false positives due to similarly named user-defined functions.

B022: 没有传递给 contextlib.suppress 的参数。不会抑制任何异常,因此此上下文管理器是多余的。注意,此规则目前并不标记抑制调用,以避免由类似命名的用户定义函数引起的潜在误报。

The following warnings are disabled by default because they are controversial. They may or may not apply to you, enable them explicitly in your configuration if you find them useful. Read below on how to enable.

下列警告默认情况下禁用,因为它们具有争议性。它们可能适用于您,也可能不适用于您,如果您认为它们有用,请在您的配置中显式启用它们。阅读下面关于如何启用。

B901: Using return x in a generator function used to be syntactically invalid in Python 2. In Python 3 return x can be used in a generator as a return value in conjunction with yield from. Users coming from Python 2 may expect the old behavior which might lead to bugs. Use native async def coroutines or mark intentional return x usage with # noqa on the same line.

B901: 在生成器函数中使用 return x 在 Python 2中曾经是语法无效的。在 Python 3中,可以在生成器中使用 x 作为结合 yield 的返回值。来自 python2的用户可能会期望旧的行为可能导致 bug。使用本地异步定义协同程序或者在同一行标记故意返回 x 用法和 # noqa。

B902: Invalid first argument used for method. Use self for instance methods, and cls for class methods (which includes new and init_subclass) or instance methods of metaclasses (detected as classes directly inheriting from type).

B902: 方法使用的第一个参数无效。对实例方法使用 self,对类方法(包括 _ new _ 和 _ init _ subclass _)或元类的实例方法(作为直接继承自类型的类检测)使用 cls。

B903: Use collections.namedtuple (or typing.NamedTuple) for data classes that only set attributes in an init method, and do nothing else. If the attributes should be mutable, define the attributes in slots to save per-instance memory and to prevent accidentally creating additional attributes on instances.

B903: 使用 collections.namedtuple (或者打字)。对于只在 _ init _ method 中设置属性,而不做其他任何事情的数据类,可以使用 NamedTuple)。如果属性应该是可变的,那么在 _ slots _ _ 中定义属性,以便保存每个实例的内存,并防止在实例上意外地创建其他属性。

B904: Within an except clause, raise exceptions with raise … from err or raise … from None to distinguish them from errors in exception handling. See the exception chaining tutorial for details.

B904: 在 except 子句中,用 raise… from err 或 raise… from None 提出异常,以区分异常处理中的错误。详细信息请参阅异常链教程。

B950: Line too long. This is a pragmatic equivalent of pycodestyle’s E501: it considers “max-line-length” but only triggers when the value has been exceeded by more than 10%. You will no longer be forced to reformat code due to the closing parenthesis being one character too far to satisfy the linter. At the same time, if you do significantly violate the line length, you will receive a message that states what the actual limit is. This is inspired by Raymond Hettinger’s “Beyond PEP 8” talk and highway patrol not stopping you if you drive < 5mph too fast. Disable E501 to avoid duplicate warnings. Like E501, this error ignores long shebangs on the first line and urls or paths that are on their own line:

B950: 队伍太长。这是一个实用的 pycodestyle 的 e501等价物: 它考虑“ max-line-length”,但只在值超过10% 时触发。您将不再被迫重新格式化代码,因为结束括号是一个字符太远,以满足临时。同时,如果您确实严重违反了行的长度,那么您将收到一条消息,说明实际的限制是什么。这个灵感来自于雷蒙德 · 赫廷格的“超越 PEP 8”演讲和高速公路巡警不会阻止你,如果你开车速度超过每小时5英里。禁用 e501以避免重复警告。像 e501一样,这个错误忽略了第一行上的 shebangs,以及它们自己行上的 url 或路径:

#! long shebang ignored

# https://some-super-long-domain-name.com/with/some/very/long/paths
url = (
    "https://some-super-long-domain-name.com/with/some/very/long/paths"
)

To enable Bugbear’s opinionated checks (B9xx), specify an –extend-select command-line option or extend-select= option in your config file (requires flake8 >=4.0):

要启用 Bugbear 的 opinionated checks (B9xx) ,请在配置文件中指定 – extend-select 命令行选项或 extend-select = option (需要 flake8 > = 4.0) :

[flake8]
max-line-length = 80
max-complexity = 12
...
extend-ignore = E501
extend-select = B950

C开头的错误

flake8-comprehensions是一个帮助你编写出更好的且易于理解的set,list,dict表达式的插件

C400-402: Unnecessary generator – rewrite as a <list/set/dict> comprehension.
It’s unnecessary to use list, set, or dict around a generator expression, since there are equivalent comprehensions for these types. For example:

Rewrite list(f(x) for x in foo) as [f(x) for x in foo]
Rewrite set(f(x) for x in foo) as {f(x) for x in foo}
Rewrite dict((x, f(x)) for x in foo) as {x: f(x) for x in foo}
C403-404: Unnecessary list comprehension – rewrite as a <set/dict> comprehension.
It’s unnecessary to use a list comprehension inside a call to set or dict, since there are equivalent comprehensions for these types. For example:

Rewrite set([f(x) for x in foo]) as {f(x) for x in foo}
Rewrite dict([(x, f(x)) for x in foo]) as {x: f(x) for x in foo}
C405-406: Unnecessary <list/tuple> literal – rewrite as a <set/dict> literal.
It’s unnecessary to use a list or tuple literal within a call to set or dict. For example:

Rewrite set([1, 2]) as {1, 2}
Rewrite set((1, 2)) as {1, 2}
Rewrite set([]) as set()
Rewrite dict([(1, 2)]) as {1: 2}
Rewrite dict(((1, 2),)) as {1: 2}
Rewrite dict([]) as {}
C408: Unnecessary <dict/list/tuple> call – rewrite as a literal.
It’s slower to call e.g. dict() than using the empty literal, because the name dict must be looked up in the global scope in case it has been rebound. Same for the other two basic types here. For example:

Rewrite dict() as {}
Rewrite dict(a=1, b=2) as {“a”: 1, “b”: 2}
Rewrite list() as []
Rewrite tuple() as ()
C409-410: Unnecessary <list/tuple> passed to <list/tuple>() – (remove the outer call to <list/tuple>()/rewrite as a <list/tuple> literal).
It’s unnecessary to use a list or tuple literal within a call to list or tuple, since there is literal syntax for these types. For example:

Rewrite tuple([1, 2]) as (1, 2)
Rewrite tuple((1, 2)) as (1, 2)
Rewrite tuple([]) as ()
Rewrite list([1, 2]) as [1, 2]
Rewrite list((1, 2)) as [1, 2]
Rewrite list([]) as []
C411: Unnecessary list call – remove the outer call to list().
It’s unnecessary to use a list around a list comprehension, since it is equivalent without it. For example:

Rewrite list([f(x) for x in foo]) as [f(x) for x in foo]
C413: Unnecessary <list/reversed> call around sorted().
It’s unnecessary to use list() around sorted() as it already returns a list. It is also unnecessary to use reversed() around sorted() as the latter has a reverse argument. For example:

Rewrite list(sorted([2, 3, 1])) as sorted([2, 3, 1])
Rewrite reversed(sorted([2, 3, 1])) as sorted([2, 3, 1], reverse=True)
Rewrite reversed(sorted([2, 3, 1], reverse=True)) as sorted([2, 3, 1])
C414: Unnecessary <list/reversed/set/sorted/tuple> call within <list/set/sorted/tuple>().
It’s unnecessary to double-cast or double-process iterables by wrapping the listed functions within list/set/sorted/tuple. For example:

Rewrite list(list(iterable)) as list(iterable)
Rewrite list(tuple(iterable)) as list(iterable)
Rewrite tuple(list(iterable)) as tuple(iterable)
Rewrite tuple(tuple(iterable)) as tuple(iterable)
Rewrite set(set(iterable)) as set(iterable)
Rewrite set(list(iterable)) as set(iterable)
Rewrite set(tuple(iterable)) as set(iterable)
Rewrite set(sorted(iterable)) as set(iterable)
Rewrite set(reversed(iterable)) as set(iterable)
Rewrite sorted(list(iterable)) as sorted(iterable)
Rewrite sorted(tuple(iterable)) as sorted(iterable)
Rewrite sorted(sorted(iterable)) as sorted(iterable)
Rewrite sorted(reversed(iterable)) as sorted(iterable)
C415: Unnecessary subscript reversal of iterable within <reversed/set/sorted>().
It’s unnecessary to reverse the order of an iterable when passing it into one of the listed functions will change the order again. For example:

Rewrite set(iterable[::-1]) as set(iterable)
Rewrite sorted(iterable)[::-1] as sorted(iterable, reverse=True)
Rewrite reversed(iterable[::-1]) as iterable
C416: Unnecessary <list/set> comprehension – rewrite using <list/set>().
It’s unnecessary to use a list comprehension if the elements are unchanged. The iterable should be wrapped in list() or set() instead. For example:

Rewrite [x for x in iterable] as list(iterable)
Rewrite {x for x in iterable} as set(iterable)

SIM开头的错误

Python-specific rules:

SIM101: Multiple isinstance-calls which can be merged into a single call by using a tuple as a second argument (example)
SIM104 : Use ‘yield from iterable’ (introduced in Python 3.3, see PEP 380) (example)
SIM105: Use ‘contextlib.suppress(…)’ instead of try-except-pass (example)
SIM107: Don’t use return in try/except and finally (example)
SIM108: Use the ternary operator if it’s reasonable (example)
SIM109: Use a tuple to compare a value against multiple values (example)
SIM110: Use any(…) (example)
SIM111: Use all(…) (example)
SIM113: Use enumerate instead of manually incrementing a counter (example)
SIM114: Combine conditions via a logical or to prevent duplicating code (example)
SIM115: Use context handler for opening files (example)
SIM116: Use a dictionary instead of many if/else equality checks (example)
SIM117: Merge with-statements that use the same scope (example)
SIM119: Moved to flake8-scream due to issue 63
SIM120 : Use ‘class FooBar:’ instead of ‘class FooBar(object):’ (example)
SIM121: Reserved for SIM908 once it’s stable
SIM125: Reserved for SIM905 once it’s stable
SIM126: Reserved for SIM906 once it’s stable
SIM127: Reserved for SIM907 once it’s stable
Simplifying Comparations:

SIM201: Use ‘a != b’ instead of ‘not a == b’ (example)
SIM202: Use ‘a == b’ instead of ‘not a != b’ (example)
SIM203: Use ‘a not in b’ instead of ‘not (a in b)’ (example)
SIM204: Moved to flake8-scream due to issue 116
SIM205: Moved to flake8-scream due to issue 116
SIM206: Moved to flake8-scream due to issue 116
SIM207: Moved to flake8-scream due to issue 116
SIM208: Use ‘a’ instead of ‘not (not a)’ (example)
SIM210: Use ‘bool(a)’ instead of ‘True if a else False’ (example)
SIM211: Use ‘not a’ instead of ‘False if a else True’ (example)
SIM212: Use ‘a if a else b’ instead of ‘b if not a else a’ (example)
SIM220: Use ‘False’ instead of ‘a and not a’ (example)
SIM221: Use ‘True’ instead of ‘a or not a’ (example)
SIM222: Use ‘True’ instead of ‘… or True’ (example)
SIM223: Use ‘False’ instead of ‘… and False’ (example)
SIM224: Reserved for SIM901 once it’s stable
SIM300: Use ‘age == 42’ instead of ‘42 == age’ (example)
Simplifying usage of dictionaries:

SIM401: Use ‘a_dict.get(key, “default_value”)’ instead of an if-block (example)
SIM118: Use ‘key in dict’ instead of ‘key in dict.keys()’ (example)
General Code Style:

SIM102: Use a single if-statement instead of nested if-statements (example)
SIM103: Return the boolean condition directly (example)
SIM106: Handle error-cases first (example). This rule was removed due to too many false-positives.
SIM112: Use CAPITAL environment variables (example)
SIM122 / SIM902: Moved to flake8-scream due to issue 125
SIM123 / SIM902: Moved to flake8-scream due to issue 130
SIM124: Reserved for SIM909 once it’s stable
Experimental rules:

Getting rules right for every possible case is hard. I don’t want to disturb peoples workflows. For this reason, flake8-simplify introduces new rules with the SIM9 prefix. Every new rule will start with SIM9 and stay there for at least 6 months. In this time people can give feedback. Once the rule is stable, the code will change to another number.

Current experimental rules:

SIM901: Use comparisons directly instead of wrapping them in a bool(…) call (example)
SIM904: Assign values to dictionary directly at initialization (example)
SIM905: Split string directly if only constants are used (example)
SIM906: Merge nested os.path.join calls (example)
SIM907: Use Optional[Type] instead of Union[Type, None] (example)
SIM908: Use dict.get(key) (example)
SIM909: Avoid reflexive assignments (example)

Disabling Rules

You might have good reasons to ignore some flake8 rules. To do that, use the standard Flake8 configuration. For example, within the setup.cfg file:

[flake8]
ignore = SIM106, SIM113, SIM119, SIM9

Examples

SIM101

# Bad
isinstance(a, int) or isinstance(a, float)

# Good
isinstance(a, (int, float))

SIM102

# Bad
if a:
    if b:
        c

# Good
if a and b:
    c

SIM105

# Bad
try:
    foo()
except ValueError:
    pass

# Good
from contextlib import suppress

with suppress(ValueError):
    foo()

Please note that contextlib.suppress is roughly 3x slower than try/except (source).

SIM107

# Bad: This example returns 3!
def foo():
    try:
        1 / 0
        return "1"
    except:
        return "2"
    finally:
        return "3"


# Good
def foo():
    return_value = None
    try:
        1 / 0
        return_value = "1"
    except:
        return_value = "2"
    finally:
        return_value = "3"  # you might also want to check if "except" happened
    return return_value

SIM108

# Bad
if a:
    b = c
else:
    b = d

# Good
b = c if a else d

SIM109

# Bad
if a == b or a == c:
    d

# Good
if a in (b, c):
    d

SIM110

# Bad
for x in iterable:
    if check(x):
        return True
return False

# Good
return any(check(x) for x in iterable)

SIM111

# Bad
for x in iterable:
    if check(x):
        return False
return True

# Good
return all(not check(x) for x in iterable)

SIM112

# Bad
os.environ["foo"]
os.environ.get("bar")

# Good
os.environ["FOO"]
os.environ.get("BAR")

SIM113

Using enumerate in simple cases like the loops below is a tiny bit easier to read as the reader does not have to figure out where / when the loop variable is incremented (or if it is incremented in multiple places).

# Bad
idx = 0
for el in iterable:
    ...
    idx += 1

# Good
for idx, el in enumerate(iterable):
    ...

SIM114

# Bad
if a:
    b
elif c:
    b

# Good
if a or c:
    b

SIM115

# Bad
f = open(...)
...  # (do something with f)
f.close()

# Good
with open(...) as f:
    ...  # (do something with f)

SIM116

# Bad
if a == "foo":
    return "bar"
elif a == "bar":
    return "baz"
elif a == "boo":
    return "ooh"
else:
    return 42

# Good
mapping = {"foo": "bar", "bar": "baz", "boo": "ooh"}
return mapping.get(a, 42)

SIM117

# Bad
with A() as a:
    with B() as b:
        print("hello")

# Good
with A() as a, B() as b:
    print("hello")

Thank you for pointing this one out, Aaron Gokaslan!

SIM118

# Bad
key in a_dict.keys()

# Good
key in a_dict

Thank you for pointing this one out, Aaron Gokaslan!

SIM120

# Bad
class FooBar(object):
    ...


# Good
class FooBar:
    ...

Both notations are equivalent in Python 3, but the second one is shorter.

SIM201

# Bad
not a == b

# Good
a != b

SIM202

# Bad
not a != b

# Good
a == b

SIM203

# Bad
not a in b

# Good
a not in b

SIM208

# Bad
not (not a)

# Good
a

SIM210

# Bad
True if a else False

# Good
bool(a)

SIM211

# Bad
False if a else True

# Good
not a

SIM212

# Bad
b if not a else a

# Good
a if a else b

SIM220

# Bad
a and not a

# Good
False

SIM221

# Bad
a or not a

# Good
True

SIM222

# Bad
... or True

# Good
True

SIM223

# Bad
... and False

# Good
False

SIM300

# Bad; This is called a "Yoda-Condition"
42 == age

# Good
age == 42

SIM401

# Bad
if key in a_dict:
    value = a_dict[key]
else:
    value = "default_value"

# Good
thing = a_dict.get(key, "default_value")

SIM901

This rule will be renamed to SIM224 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 23rd of January and will end on 23rd of August 2022.

# Bad
bool(a == b)

# Good
a == b

SIM904

This rule will be renamed to SIM224 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 12th of February and will end on 12th of September 2022.

# Bad
a = {}
a["b"] = "c"

# Good
a = {"b": "c"}

SIM905

This rule will be renamed to SIM225 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 13th of February and will end on 13th of September 2022.

# Bad
domains = "de com net org".split()

# Good
domains = ["de", "com", "net", "org"]

SIM906

This rule will be renamed to SIM126 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 20th of February and will end on 20th of September 2022.

# Bad
os.path.join(a, os.path.join(b, c))

# Good
os.path.join(a, b, c)

SIM907

This rule will be renamed to SIM127 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 28th of March and will end on 28th of September 2022.

# Bad
def foo(a: Union[int, None]) -> Union[int, None]:
    return a


# Good
def foo(a: Optional[int]) -> Optional[int]:
    return a

SIM908

This rule will be renamed to SIM121 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 28th of March and will end on 28th of September 2022.

# Bad
name = "some_default"
if "some_key" in some_dict:
    name = some_dict["some_key"]

# Good
name = some_dict.get("some_key", "some_default")

SIM909

Thank you Ryan Delaney for the idea!

This rule will be renamed to SIM124 after its 6-month trial period is over. Please report any issues you encounter with this rule!

The trial period starts on 28th of March and will end on 28th of September 2022.

# Bad
foo = foo

# Good: Nothing. Reflexive assignments have no purpose.

or

# Bad
foo = foo = 42

# Good
foo = 42
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/194314.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 100——第10例

    100——第10例

  • 浙江新增python课程_浙江教育新规重磅来袭:今年9月起,八年级新增Python编程课程…

    浙江新增python课程_浙江教育新规重磅来袭:今年9月起,八年级新增Python编程课程…浙江新学期将会对信息课程做调,三到九年级信息技术课将同步替换新器材。其中最大的变化是,八年级将新增Python课程内容。新高一信息技术编程语言由VB替换为Python,大数据、人工智能、程序设计与算法按照教材规划五六年级开始接触。有网友疑惑:“这算不算是超前教育了呢?”其实不然。早在2012年,日本就在中小学中普及编程教育科目;2014年,英国教育部把编程列入了学校的必修课程,让5岁以上的孩子都必…

  • go get 使用代理

    go get 使用代理众所周知的原因,goget命令在提取一些工程或依赖时(如golang.org域名)被墙掉。通过使用vpn或代理的方法可以解决。买VPN这个就不多说了,买vpn,相当于直接连接。使用代理通过shell环境变量exporthttp_proxy=http://ip:portgogetgolang.org/xxx通过设置git代理这也是go官方指导。gitconfig–globalhttp.

  • 阿里云mysql读写分离实现_MySQL-Proxy实现MySQL读写分离

    阿里云mysql读写分离实现_MySQL-Proxy实现MySQL读写分离要实现读写分离,需要先有搭建MySQL的主从环境介绍master192.168.133.128slave192.168.133.132proxy192.168.133.130首先在mysql-proxy上安装依赖包yum-yinstallgccgcc-c++autoconflibevent-develpkgconfiglibtoolmysql-devellibterm…

  • mysql修改用户密码命令_linux下mysql修改用户密码命令

    mysql修改用户密码命令_linux下mysql修改用户密码命令Linux下有时候想要修改用户密码用什么命令呢?下面由学习啦小编为大家整理了linux下mysql修改用户密码命令的相关知识,希望对大家有帮助!linux的mysql修改用户密码命令详解修改的用户都以root为列。分为两种情况:linux修改mysql用户密码情况一、拥有原来的myql的root的密码方法一:在mysql系统外,使用mysqladmin#mysqladmin-uroot-p…

  • spring boot 系列之五:spring boot 通过devtools进行热部署

    前面已经分享过四篇随笔:在上述代码操作的过程中肯定也发现了一个问题:哪怕是一个个小小的修改,都必须要重新启动服务才能使修改生效。那能不能通过配置实现springboot的热部署呢?答案是肯定的。

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号