【问题标题】:Pylint marking code as an error that worksPylint 将代码标记为有效的错误
【发布时间】:2020-11-21 17:40:15
【问题描述】:

我一直在使用 python 与 Tor 和 Stem 进行交互。 在代码中的controller.signal(Signal.NEWNYM) 线上,它总是将Signal 标记为错误

Instance of 'Enum' has no 'NEWNYM' memberpylint(no-member)

我不知道它为什么这样做。这部分代码是 Stem 官方网站用来更改 IP 地址的代码。

我也曾一度关闭pylint,但这意味着我不能轻易看到拼写错误。 每个“修复”都只是让所有错误检查进行,它是干库的错误吗?

我的 IDE 是 VScode,如果有帮助,我正在 Ubuntu 上的 Python 3.6.9 64bit 工作。

import requests
import time
from stem import Signal
from stem.control import Controller


def get_current_ip():
     session = requests.session()

    # TO Request URL with SOCKS over TOR
    session.proxies = {}
    session.proxies['http']='socks5h://localhost:9050'
    session.proxies['https']='socks5h://localhost:9050'

    try:
        r = session.get('http://httpbin.org/ip')
    except Exception as e:
        print(e)
    else:
        return r.text


def renew_tor_ip():
    with Controller.from_port(port = 9051) as controller:
        controller.authenticate()
        controller.signal(Signal.NEWNYM)

if __name__ == "__main__":
    for i in range(4):
        print(get_current_ip())
        renew_tor_ip()
        time.sleep(5)

【问题讨论】:

  • 是的,我的代码有效,只是真的很烦人,所以不是世界末日或任何事情。 Stem 是最新版本,我相信 pylint 是 2.5.3 版。

标签: python python-3.x pylint tor stem


【解决方案1】:

这是 VSCode 中的一个问题,这是其错误检查的问题,并且认为实例没有成员,当他们做唯一的方法来阻止这种情况时,将在 VSCode 设置中添加代码来更改它,以便对 Pylint 进行错误检查走开

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多