bmistry12 / twitter-scraper

Re-defined variable from outer scope PYL-W0621
Anti-pattern
Major
2 years ago4 years old
Redefining name 'tweet_text' from outer scope (line 79)
54    return filtered_file_name
55
56
57def _sentiment_analyis(tweet_text):58    """Perform sentiment analysis with TextBlob.
59    https://planspace.org/20150607-textblob_sentiment/.
60    """
Redefining name 'index' from outer scope (line 77)
41        known_locations += us_file.read().splitlines()
42    with open('./data/countries', 'r', encoding="utf-8") as country_file:
43        known_locations += country_file.read().splitlines()
44    for index, _ in enumerate(tweet):45        loc = tweet[index]["User-Location"]
46        if loc in ["", None]:
47            continue
Redefining name 'tweet_json' from outer scope (line 75)
33    known_locations = []
34    tweets_with_known_location = []
35    with open(data_file_name, 'r', encoding="utf-8") as tweet_file:
36        tweet_json = tweet_file.read()37    tweet = json.loads(tweet_json)
38    with open("./data/cities", 'r', encoding="utf-8") as city_file:
39        known_locations += city_file.read().splitlines()
Redefining name 'tweet_file' from outer scope (line 74)
32        raise RuntimeError()
33    known_locations = []
34    tweets_with_known_location = []
35    with open(data_file_name, 'r', encoding="utf-8") as tweet_file:36        tweet_json = tweet_file.read()
37    tweet = json.loads(tweet_json)
38    with open("./data/cities", 'r', encoding="utf-8") as city_file:
Redefining name 'index' from outer scope (line 77)
13        duplicate_freq[item] = tweets_with_sentiment.count(item)
14    tweets = duplicate_freq.keys()
15    df = pd.DataFrame(columns=['tweet', 'sentiment', 'count'])
16    for index, item in enumerate(tweets):17        if not isinstance(item, tuple):
18            continue
19        tweet, sentiment = item