简体   繁体   English

Pylint 将代码标记为有效的错误

[英]Pylint marking code as an error that works

I've been using python to interact with Tor and Stem.我一直在使用 python 与 Tor 和 Stem 进行交互。 And on line controller.signal(Signal.NEWNYM) in the code it's always marking Signal with the error在代码中的controller.signal(Signal.NEWNYM)线上,它总是将Signal标记为错误

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

I have no idea why its doing this.我不知道它为什么这样做。 This particular section of code is what the official Stem website uses to change IP address.这部分代码是 Stem 官方网站用来更改 IP 地址的代码。

I have also turned pylint off at one point but that means i can't see typos easily.我也曾一度关闭了pylint ,但这意味着我不能轻易看到拼写错误。 Every "fix" just makes all error checking go, is it a bug with the stem library?每个“修复”都会检查 go 的所有错误,它是干库的错误吗?

My IDE is VScode and I'm working in Python 3.6.9 64bit on Ubuntu if that helps.我的 IDE 是VScode ,如果有帮助,我正在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)

This is a problem in VSCode, it is a problem with its error checking and thinking instances have no member when they do the only way to stop this would be in VSCode setting and adding code to change it so error checking for Pylint would go away这是 VSCode 中的一个问题,它的错误检查存在问题,并且认为实例没有成员,当它们停止这种情况的唯一方法是在 VSCode 设置中并添加代码来更改它,因此对 Pylint 的错误检查将 go

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM