PyCharm no inspection修饰

  • PyCharm # no inspection修饰的作用
    让PyCharm 在代码检查时人为跳过某些特定部分的代码检查,便于强迫症和优化代码提示

  • 使用方法
    在需要跳过代码校验的部分加上注释即可
    比如

def temp(*args):
    try:
        return sum(args)
    except Exception:  # 这里会触发 Too broad exception clause 校验
        return 0
实际效果图
  • 检查注释对照表
注释 对应检查说明
# noinspection PyAbstractClass This inspection detects when not all abstract properties/methods are defined in a subclass
# noinspection PyArgumentList This inspection reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments (e.g. duplicate named arguments) and incorrect argument order. Decorators are analyzed, too.
# noinspection PyArgumentEqualDefault This inspection highlights situations, where argument passed to function is equal to default parameter value
# noinspection PyAssignmentToLoopOrWithParameter Checks for cases when you rewrite loop variable with inner loop
    for i in xrange(5):
        for i in xrange(20, 25):
            print("Inner", i)
            print("Outer", i)
It also warns you if variable declared in with statement is redeclared inside of statement body:
    with open("file") as f:
        f.read()
        with open("file") as f:
# noinspection PyAsyncCall This inspection highlights coroutines which were called without await
# noinspection PyAugmentAssignment This inspection highlights assignment that can be replaced with augmented assignment.
# noinspection PyAttributeOutsideInit This inspection detects instance attribute definition outside __init__ method
# noinspection PyBroadException This inspection highlights too broad exception clauses such as no exception class specified, or specified as 'Exception'.
# noinspection PyByteLiteral This inspection detects characters > 255 in byte literals.
# noinspection PyCallByClass This inspection checks for calls of a method by class while passing an instance of a different class as self parameter:
    foo = Foo()
    Bar.baz(foo, *more)
Sometimes this may be intentional and correct. But when unintentional, this leads to subtle bugs.
# noinspection PyCallingNonCallable This inspection highlights attempts to call objects which are not callable, like, for example, tuples.
# noinspection PyChainedComparisons This inspection highlights chained comparisons that can be simplified.
# noinspection PyClassHasNoInit This inspection used when a class has no __init__ method, neither its parent classes.
# noinspection PyClassicStyleClass This inspection detects classic style classes usage.
# noinspection PyComparisonWithNone This inspection highlights comparisons with None. That type of comparisons should always be done with 'is' or 'is not', never the equality operators.
# noinspection PyCompatibility Enable this inspection if you need your code to be compatible with a range of Python versions (for example, if you're building a library). The range of Python versions with which the code needs to be compatible can be specified in the inspection settings.
# noinspection PyDataclass This inspection detects invalid definitions and usages of classes created with dataclasses or attr modules.
# noinspection PyDecorator This inspection reports usages of @classmethod or @staticmethod decorators on functions outside of a class.
# noinspection PyDefaultArgument This inspection detects when a mutable value as list or dictionary is detected in a default value for an argument. Default argument values are evaluated only once at function definition time, which means that modifying the default value of the argument will affect all subsequent calls of the function.
# noinspection PyDeprecation This inspection highlights usages of Python functions, classes or methods which are marked as deprecated (which raise a DeprecationWarning or a PendingDeprecationWarning).
# noinspection PyDictCreation This inspection detects situations when dictionary creation could be rewritten with dictionary literal.
# noinspection PyDictDuplicateKeys This inspection highlights using the same value as dictionary key twice.
# noinspection PyDocstringTypes This inspection highlights types in docstring which don't match dynamically inferred types.
# noinspection PyDunderSlots This inspection detects invalid definition of __slots__ in a class.
# noinspection PyExceptClausesOrder This inspection highlights situations when except clauses are not in the correct order (from the more specific to the more generic) or one exception class is caught twice. If you don't fix the order, some exceptions may not be catched by the most specific handler.
# noinspection PyExceptionInherit This inspection detects when a custom exception class is raised but doesn't inherit from the builtin "Exception" class.
# noinspection PyFromFutureImport This inspection detects 'from __future__ import' statements which are used not in the beginning of a file.
# noinspection PyGlobalUndefined This inspection is used when a variable is defined through the "global" statement but the variable is not defined in the module scope.
# noinspection PyInconsistentIndentation This inspection reports inconsistent indentation in Python source files (for example, use of a mixture of tabs and spaces).
# noinspection PyIncorrectDocstring This inspection detects mismatched parameters in a docstring. Please note that it doesn't warn you of missing parameters, if none of them is mentioned in a docstring.
# noinspection PyInitNewSignature This inspection checks mutual compatibility of __new__ and __init__ signatures.
# noinspection PyInterpreter This inspection notifies you if the current project has no Python interpreter configured or an invalid Python interpreter.
# noinspection PyListCreation This inspection detects situations when list creation could be rewritten with list literal.
# noinspection PyMandatoryEncoding This inspection detects lack of encoding magic comment for file.
# noinspection PyMethodFirstArgAssignment This inspection detects cases when first parameter, such as 'self' or 'cls', is reassigned in a method. In most cases imaginable, there's no point in such reassignment, and it indicates an error.
# noinspection PyMethodMayBeStatic This inspection detects any methods which may safely be made static.
# noinspection PyMethodOverriding This inspection detects inconsistencies in overriding method signatures.
# noinspection PyMethodParameters This inspection looks for methods that lack a first parameter (which is usually named self ).
# noinspection PyMissingConstructor This inspection warns if call to super constructor in class is missed
# noinspection PyMissingOrEmptyDocstring This inspection detects lack of docstring and an empty docstring.
# noinspection PyMissingTypeHints This inspection detects lack of type hints for function declaration in one of the two formats: parameter annotations or a type comment
# noinspection PyNamedTuple This inspection detects invalid definition of namedtuple.
# noinspection PyNestedDecorators This inspection looks for certain decorators that don't nest well.
# noinspection PyNonAsciiChar This inspection detects file contains non-ASCII characters and doesn't have an encoding declaration at the top.
# noinspection PyNoneFunctionAssignment This inspection is similar to pylint inspection E1111. It highlights situations when an assignment is done on a function call but the inferred function doesn't return anything.
# noinspection PyOldStyleClasses This inspection highlights occurrences of new-style class features in old-style classes.
# noinspection PyOverloads This inspection validates overloads in regular Python files.
# noinspection PyPackageRequirements This inspection warns about imported or required, but not installed packages.
# noinspection PyPep8 This inspection runs the pep8.py tool to check for violations of the PEP 8 coding style guide.
# noinspection PyPep8Naming This inspection checks the PEP8 naming conventions.
# noinspection PyPropertyAccess This inspection checks that properties are accessed correctly: read-only not set, write-only not read, non-deletable not deleted.
# noinspection PyPropertyDefinition This inspection checks that arguments to property() and functions annotated with @property and friends look reasonably.
# noinspection PyProtectedMember This inspection warns if a protected member is accessed outside the class, a descendant of the class where it's defined or a module.
# noinspection PyProtocol This inspection detects invalid definitions and usages of protocols introduced in PEP-544.
# noinspection PyRedeclaration This inspection detects unconditional redeclarations of names without being used in between, like this:
def x(): pass
x = 2
It applies to function and class declarations, and top-level assignments.
# noinspection PyRedundantParentheses This inspection highlights redundant parentheses in statements.
# noinspection PyReturnFromInit This inspection reports occurrences of return statements with a return value inside __init__ methods of classes. A constructor should not return any value.
# noinspection PySetFunctionToLiteral This inspection detects call for function "set" which can be replaced with set literal.
# noinspection PyShadowingBuiltins This inspection detects shadowing built-in names, such as 'len' or 'list'.
# noinspection PyShadowingNames This inspection detects shadowing names defined in outer scopes
# noinspection PySimplifyBooleanCheck This inspection detects equality comparison with a boolean literal.
# noinspection PySingleQuotedDocstring This inspection highlights docstrings not using triple double-quoted string format.
# noinspection PyStatementEffect This inspection detects statements without any effect.
# noinspection PyStringException This inspection detects when a string exception is raised.
# noinspection PyStringFormat This inspection detects errors in string formatting operations.
# noinspection PySuperArguments This inspection check that in any call to super(A, B), B either is an instance of A or a subclass of A.
# noinspection PyTestParametrized Test function, decorated with @pytest.mark.parametrize, must have arguments to accept parameters from decorator
# noinspection PyTrailingSemicolon This inspection detects trailing semicolons in statements.
# noinspection PyTupleAssignmentBalance This inspection check that the number of expressions on right-hand side and targets on left-hand side are the same.
# noinspection PyTupleItemAssignment This inspection detects assignments to tuple item.
# noinspection PyTypeChecker This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations.
# noinspection PyTypeHints This inspection detects invalid usages of type hints.
# noinspection PyUnboundLocalVariable This inspection warns about local variables referenced before assignment.
# noinspection PyUnnecessaryBackslash This inspection highlights backslashes in places where line continuation is implicit (inside (), [], {}).
# noinspection PyUnreachableCode This inspection detects code which can not be normally reached.
# noinspection PyUnresolvedReferences This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
# noinspection PyUnusedLocal This inspection highlights local variables,parameters or local functions unused in scope.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,496评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,407评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,632评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,180评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,198评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,165评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,052评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,910评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,324评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,542评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,711评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,424评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,017评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,668评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,823评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,722评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,611评论 2 353

推荐阅读更多精彩内容

  • 1. Annotations(注解:5个) Annotation Use Style(注解使用风格) 这项检查可以...
    onlyHalfSoul阅读 6,047评论 1 1
  • 洗衣机的故事一 赵伟明回到家里时已经凌晨三点。他丝毫没有刚杀过人的恐惧,他慢慢地走近小区,犹如地狱修罗般穿着带血的...
    冰糖葫芦圈阅读 1,127评论 0 1
  • 这就是我,喜欢一个人去看画展,喜欢一个人在小街小巷中穿行,喜欢自己一个静静的发呆…… 于是,在24号...
    七叶Y阅读 748评论 12 8
  • == 进行地址的比较 equals 进行值的比较 compareTo abc <abcd abf>abcd
    Xr丶_c967阅读 243评论 0 0
  • 你虽不善辩 却总在奉献 用红色的本真 染满素颜 诉说深深爱恋 四季轮回地生长期 长芽,抽叶,开花, 这是怎样的别出...
    青果文学馆阅读 419评论 0 0