Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Fixes mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLonelyGhost committed Jun 12, 2021
1 parent 13d87f2 commit b7824eb
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 49 deletions.
88 changes: 71 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,32 @@ better-exceptions = "^0.2.2"
pytest = "^5.1"
pytest-cov = "^2.7"
flake8 = "^3.7.9"
mypy = "^0.761"
mypy = ">=0.800"
black = "^19.10b0"
types-toml = "^0.1"
types-PyYAML = "^0.1"
types-requests = "^0.1"
types-redis = "^3.5"

[tool.poetry.scripts]
tor-moderator = "tor.cli.main:main"

[tool.poetry.extras]
ci = ['pytest', 'pytest-cov']

[[tool.mypy.overrides]]
module = [
"praw",
"praw.*",
"prawcore",
"prawcore.*",
"blossom_wrapper",
"beeline",
"slackclient",
"pytest",
]
ignore_missing_imports = true

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
2 changes: 1 addition & 1 deletion test/core/test_admin_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pytest # type: ignore
import pytest
from unittest.mock import MagicMock
from unittest.mock import patch

Expand Down
2 changes: 1 addition & 1 deletion tor/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import logging

from praw import Reddit # type: ignore
from praw import Reddit
from dotenv import load_dotenv
import beeline

Expand Down
26 changes: 9 additions & 17 deletions tor/core/config.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import datetime
import os

import bugsnag
from blossom_wrapper import BlossomAPI
from praw import Reddit # type: ignore
from praw.models import Subreddit # type: ignore
from praw.models.reddit.subreddit import ModeratorRelationship # type: ignore
from slackclient import SlackClient # type: ignore
from praw import Reddit
from praw.models import Subreddit
from praw.models.reddit.subreddit import ModeratorRelationship
from slackclient import SlackClient
from typing import Dict, List, Union

from tor import __root__, __version__
from tor.core import cached_property

# Load configuration regardless of if bugsnag is setup correctly
try:
import bugsnag # type: ignore
except ImportError:
# If loading from setup.py or bugsnag isn't installed, we
# don't want to bomb out completely
bugsnag = None


class Config(object):
"""
A singleton object for checking global configuration from
Expand Down Expand Up @@ -52,10 +44,10 @@ class Config(object):
@cached_property
def blossom(self):
return BlossomAPI(
email=os.getenv('BLOSSOM_EMAIL'),
password=os.getenv('BLOSSOM_PASSWORD'),
api_key=os.getenv('BLOSSOM_API_KEY'),
api_base_url=os.getenv('BLOSSOM_API_URL'),
email=os.environ['BLOSSOM_EMAIL'],
password=os.environ['BLOSSOM_PASSWORD'],
api_key=os.environ['BLOSSOM_API_KEY'],
api_base_url=os.environ['BLOSSOM_API_URL'],
)

@cached_property
Expand Down
6 changes: 3 additions & 3 deletions tor/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import beeline
from blossom_wrapper import BlossomStatus
from praw.exceptions import APIException # type: ignore
from praw.models import Comment, Submission, Subreddit # type: ignore
from prawcore.exceptions import RequestException, ServerError, Forbidden, NotFound # type: ignore
from praw.exceptions import APIException
from praw.models import Comment, Submission, Subreddit
from prawcore.exceptions import RequestException, ServerError, Forbidden, NotFound

import tor.core
from tor.core import __version__
Expand Down
6 changes: 3 additions & 3 deletions tor/core/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import re

import beeline
from praw.exceptions import ClientException # type: ignore
from praw.models import Comment, Message # type: ignore
from praw.models.reddit.mixins import InboxableMixin # type: ignore
from praw.exceptions import ClientException
from praw.models import Comment, Message
from praw.models.reddit.mixins import InboxableMixin

from tor import __BOT_NAMES__
from tor.core import validation
Expand Down
2 changes: 1 addition & 1 deletion tor/core/initialize.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

import beeline
from bugsnag.handlers import BugsnagHandler # type: ignore
from bugsnag.handlers import BugsnagHandler

from tor.core.config import Config
from tor.core.helpers import clean_list, get_wiki_page
Expand Down
2 changes: 1 addition & 1 deletion tor/core/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import beeline
from blossom_wrapper import BlossomStatus
from praw.models import Submission # type: ignore
from praw.models import Submission

from tor.core.config import Config
from tor.core.helpers import _
Expand Down
2 changes: 1 addition & 1 deletion tor/core/user_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import beeline
from blossom_wrapper import BlossomStatus
from praw.models import Comment, Message, Redditor, Submission # type: ignore
from praw.models import Comment, Message, Redditor, Submission

from tor.core.config import Config
from tor.core.helpers import (_, get_wiki_page,
Expand Down
2 changes: 1 addition & 1 deletion tor/core/validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Union, Tuple

from praw.models import Comment, Redditor, Submission # type: ignore
from praw.models import Comment, Redditor, Submission

from tor.core.config import Config
from tor.strings import translation
Expand Down
2 changes: 1 addition & 1 deletion tor/helpers/flair.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from blossom_wrapper import BlossomStatus
from praw.models import Comment, Redditor, Submission # type: ignore
from praw.models import Comment, Redditor, Submission

from tor import __BOT_NAMES__
from tor.core.config import Config
Expand Down
2 changes: 1 addition & 1 deletion tor/helpers/reddit_ids.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from blossom_wrapper import BlossomStatus
from praw.models import Submission # type: ignore
from praw.models import Submission

from tor.core.config import Config

Expand Down

0 comments on commit b7824eb

Please sign in to comment.