0

I've been using python to interact with Tor and Stem. And on line controller.signal(Signal.NEWNYM) in the code it's always marking Signal with the error

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.

I have also turned pylint off at one point but that means i can't see typos easily. Every "fix" just makes all error checking go, is it a bug with the stem library?

My IDE is VScode and I'm working in Python 3.6.9 64bit on Ubuntu if that helps.

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)
martineau
  • 119,623
  • 25
  • 170
  • 301
  • Yeah my code works, it's just really annoying so not the end of the world or anything. Stem is the newest version I believe pylint is version 2.5.3. – Marty Vestor Jul 31 '20 at 21:44

2 Answers2

0

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

Leo Gaunt
  • 711
  • 1
  • 8
  • 29
0

I have the same problem and I have "solved" it by using a string value instead of the Signal enum:

controller.signal("NEWNYM")
sergio_teula
  • 91
  • 1
  • 8