Skip to content

Commit

Permalink
Fix pyright warnings after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
codders committed Feb 5, 2024
1 parent a21676a commit 2e74d90
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions flathunter/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Wrap configuration options as an object"""
import os
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, List

import json
import yaml
Expand Down Expand Up @@ -150,7 +150,7 @@ def get(self, key, value=None):
"""Emulate dictionary"""
return self.config.get(key, value)

def _read_yaml_path(self, path, default_value=None):
def _read_yaml_path(self, path, default_value):
"""Resolve a dotted variable path in nested dictionaries"""
config = self.config
parts = path.split('.')
Expand Down Expand Up @@ -192,18 +192,18 @@ def get_captcha_afterlogin_string(self):

def database_location(self):
"""Return the location of the database folder"""
config_database_location = self._read_yaml_path('database_location')
config_database_location = self._read_yaml_path('database_location', None)
if config_database_location is not None:
return config_database_location
return os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/..")

def target_urls(self):
def target_urls(self) -> List[str]:
"""List of target URLs for crawling"""
return self._read_yaml_path('urls', [])

def verbose_logging(self):
"""Return true if logging should be verbose"""
return self._read_yaml_path('verbose') is not None
return self._read_yaml_path('verbose', None) is not None

Check warning on line 206 in flathunter/config.py

View check run for this annotation

Codecov / codecov/patch

flathunter/config.py#L206

Added line #L206 was not covered by tests

def loop_is_active(self):
"""Return true if flathunter should be crawling in a loop"""
Expand Down Expand Up @@ -248,7 +248,7 @@ def message_format(self):
return config_format
return self.DEFAULT_MESSAGE_FORMAT

def notifiers(self):
def notifiers(self) -> List[str]:
"""List of currently-active notifiers"""
return self._read_yaml_path('notifiers', [])

Expand All @@ -264,7 +264,7 @@ def telegram_notify_with_images(self) -> bool:

def telegram_receiver_ids(self):
"""Static list of receiver IDs for notification messages"""
return self._read_yaml_path('telegram.receiver_ids') or []
return self._read_yaml_path('telegram.receiver_ids', [])

def mattermost_webhook_url(self):
"""Webhook for sending Mattermost messages"""
Expand All @@ -274,15 +274,15 @@ def slack_webhook_url(self):
"""Webhook for sending Slack messages"""
return self._read_yaml_path('slack.webhook_url', "")

def apprise_urls(self):
def apprise_urls(self) -> List[str]:
"""Notification URLs for Apprise"""
return self._read_yaml_path('apprise', [])

def _get_imagetyperz_token(self):
"""API Token for Imagetyperz"""
return self._read_yaml_path("captcha.imagetyperz.token", "")

def get_twocaptcha_key(self):
def get_twocaptcha_key(self) -> str:
"""API Token for 2captcha"""
return self._read_yaml_path("captcha.2captcha.api_key", "")

Expand Down
2 changes: 1 addition & 1 deletion flathunter/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class AbstractFilter(ABC):
"""Abstract base class for filters"""

def is_interesting(self, _expose):
def is_interesting(self, _expose) -> bool:
"""Return True if an expose should be included in the output, False otherwise"""
return True

Expand Down
2 changes: 1 addition & 1 deletion flathunter/hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def try_crawl(searcher, url, max_pages):
for searcher in self.config.searchers()
for url in self.config.target_urls()])

def hunt_flats(self, max_pages=None):
def hunt_flats(self, max_pages: None|int = None):
"""Crawl, process and filter exposes"""
filter_set = Filter.builder() \
.read_config(self.config) \
Expand Down
2 changes: 1 addition & 1 deletion flathunter/web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib import parse

from flask import render_template, jsonify, request, session, redirect
from flask_api import status
from flask_api import status # type: ignore

from flathunter.web import app, log
from flathunter.web.util import sanitize_float
Expand Down

0 comments on commit 2e74d90

Please sign in to comment.