我有一个房产装饰师所以:
def Property(f):
"""
Allow readable properties without voodoo.
"""
fget, fset, fdel = f()
fdoc = f.__doc__
return property(fget, fset, fdel, fdoc)
Run Code Online (Sandbox Code Playgroud)
使用(例如)所以:
@Property
def method():
""""""
def fget(self):
return some expression...
return fget, None, None
Run Code Online (Sandbox Code Playgroud)
所以我的问题是关于这样做的python方式.Pydev抱怨说
"方法
method应该有自己作为第一个参数"
而且pylint给了我
方法没有争论
我知道我可以在pydev中关闭此错误消息,但我想知道是否有更好的方法来管理不将self作为参数的方法,我可以做得更好.
我有一个非常简单的问题,我一直找不到解决方案,所以我想我会在这里试试我的“运气”。
我有一个完全使用变量和静态文本创建的字符串。如下:
filename_gps = 'id' + str(trip_id) + '_gps_did' + did + '_start' + str(trip_start) + '_end' + str(trip_end) + '.json'
Run Code Online (Sandbox Code Playgroud)
但是我的问题是 pylint 抱怨这个字符串表示太长了。这就是问题所在。我如何在多行上格式化这个字符串表示而不让它看起来很奇怪并且仍然保持在 pylint 的“规则”内?
有一次,我最终使它看起来像这样,但是看起来令人难以置信的“丑陋”:
filename_gps = 'id' + str(
trip_id) + '_gps_did' + did + '_start' + str(
trip_start) + '_end' + str(
trip_end) + '.json'
Run Code Online (Sandbox Code Playgroud)
我发现如果我这样格式化它,它会遵循 pylint 的“规则”:
filename_gps = 'id' + str(
trip_id) + '_gps_did' + did + '_start' + str(
trip_start) + '_end' + str(
trip_end) + '.json'
Run Code Online (Sandbox Code Playgroud)
哪个看起来更“漂亮”,但如果我没有“str()”强制转换,我将如何创建这样的字符串?
我怀疑 Python 2.x 和 3.x …
例如,是否可以按行或按类别或两者排序?
我看到可以使用模板:How do I get Pylint message IDs to show up after pylint-1.0.0?
在 PyCharm 中,我配置了一个外部工具来调用 pyLint:
$FileName$ --msg-template={line}:" "[{msg_id}"-"({symbol})," "{obj}]:" "{msg}
Run Code Online (Sandbox Code Playgroud)
现在,我想对这个输出结果进行排序。
谢谢
filename_format = prefix + startdate.strftime('%Y%m%d') + '_' + enddate.strftime('%Y%m%d')
LOGGER.info('Filename format: ' + filename_format)
Run Code Online (Sandbox Code Playgroud)
对于以上,我得到
指定字符串格式参数作为日志函数参数(logging-not-lazy)
当我运行 pylint. 哪个部分是错误?
C:\ Users \ dominic.lopes \ Desktop> pylint Exception.py *************模块异常Exception.py:1:0:C0103:模块名称“ Exception”不符合snake_case命名样式(无效名称)Exception.py:11:4:C0103:常量名称“ x”与UPPER_CASE命名样式(无效名称)Exception.py:12:4:C0103:常量名称“ y” “不符合UPPER_CASE命名样式(无效名称)Exception.py:21:44:E0602:未定义的变量'count'(未定义的变量)
您的代码被评为3.85 / 10(上一次运行:6.92 / 10,-3.08)
这是我得到的错误回溯
我是编程新手,我下载了Python,并使其在Visual Studio Code中运行。我在弄乱turtle模块及其功能。
这些函数本身可以工作,但pylint会将其标记为错误,并说没有像我编写的代码那样的“成员”。
我将如何解决该错误?(我不想将其设置为“忽略”该问题,而是认识到我输入的代码是有效的并且来自于turtle模块)
当我使用 pylint 时:
import pylint.lint
options = [
filename,
"--output-format=json"
]
results = pylint.lint.Run(options, do_exit=False)
messages = results.linter.reporter.messages
Run Code Online (Sandbox Code Playgroud)
我的messages变量具有正确的信息JSON。但是,pylint 会JSON在控制台中打印消息...
我怎样才能防止print()pylint?
此选项不起作用:
options = [
filename,
"--output-format=json",
"--reports=no" # Tells whether to display a full report or only the messages.
]
Run Code Online (Sandbox Code Playgroud)
见https://pylint.readthedocs.io/en/stable/technical_reference/features.html#reports-options
尝试学习PyQt5时遇到VS Code中的此问题,“ PyQt5.QtWidgets”模块中没有名称“ QApplication”,“ PyQt5.QtWidgets”模块中没有名称“ QWidget”。
我不确定这是否是pylint问题或其他问题。我已经确认PyQt5已随pip3列表一起安装,但我似乎无法弄清楚问题所在。
import sys
from PyQt5.QtWidgets import QApplication, QWidget
def app():
my_app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle("Test")
w.show()
sys.exit(my_app.exec_())
app()
Run Code Online (Sandbox Code Playgroud)
我希望这个错误不会一直显示,但是会阻止我在VS Code中运行。任何帮助或建议表示赞赏。
为什么我在 Visual Studio Code 中收到未使用的变量警告,当有明显的用途时 - 仅在有问题的变量声明下方 3 行?这里对变量给出警告
found_r_object_id_in_cara
Run Code Online (Sandbox Code Playgroud)
该变量在声明下方几行的“if”语句中被引用。
Pylint missing-docstring 似乎忽略了类中的一些函数和私有方法。
如何让 pylint 强制所有函数和方法都必须在某个存储库中具有文档字符串?
我发现的一种选择是禁用忽略私有函数:
no-docstring-rgx='a^'
pylint ×10
python ×8
python-3.x ×5
decorator ×1
pycharm ×1
pydev ×1
pylintrc ×1
pyqt5 ×1
python-2.7 ×1
string ×1