Consolidate flake8 settings
Consolidates sane flake8 settings to pyproject with the Flake8-pyproject plugin. Does not change logic of test workflow but allows base settings to live in pyproject for anyone using flake8 as an external linter (e.g. vscode) Also fixes some flake8 errors that were not being picked up by current testing, mostly unused imports.
This commit is contained in:
8
.github/workflows/test.yml
vendored
8
.github/workflows/test.yml
vendored
@@ -3,8 +3,12 @@ name: Python Test
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, development ]
|
branches: [ master, development ]
|
||||||
|
paths-ignore:
|
||||||
|
- "*.md"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master, development ]
|
branches: [ master, development ]
|
||||||
|
paths-ignore:
|
||||||
|
- "*.md"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -27,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip flake8 pytest pytest-cov
|
python -m pip install --upgrade pip Flake8-pyproject pytest pytest-cov
|
||||||
pip install .
|
pip install .
|
||||||
|
|
||||||
- name: Make configuration for tests
|
- name: Make configuration for tests
|
||||||
@@ -38,7 +42,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Lint with flake8
|
- name: Lint with flake8
|
||||||
run: |
|
run: |
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
flake8 . --select=E9,F63,F7,F82
|
||||||
|
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
# Bulk Downloader for Reddit
|
# Bulk Downloader for Reddit
|
||||||
|
|
||||||
[](https://pypi.python.org/pypi/bdfr)
|
[](https://pypi.python.org/pypi/bdfr)
|
||||||
[](https://pypi.python.org/pypi/bdfr)
|
[](https://pypi.python.org/pypi/bdfr)
|
||||||
|
[](https://pypi.python.org/pypi/bdfr)
|
||||||
|
[](https://aur.archlinux.org/packages/python-bdfr)
|
||||||
[](https://github.com/aliparlakci/bulk-downloader-for-reddit/actions/workflows/test.yml)
|
[](https://github.com/aliparlakci/bulk-downloader-for-reddit/actions/workflows/test.yml)
|
||||||
|
[](https://github.com/psf/black)
|
||||||
|
[](https://github.com/pre-commit/pre-commit)
|
||||||
|
|
||||||
This is a tool to download submissions or submission data from Reddit. It can be used to archive data or even crawl Reddit to gather research data. The BDFR is flexible and can be used in scripts if needed through an extensive command-line interface. [List of currently supported sources](#list-of-currently-supported-sources)
|
This is a tool to download submissions or submission data from Reddit. It can be used to archive data or even crawl Reddit to gather research data. The BDFR is flexible and can be used in scripts if needed through an extensive command-line interface. [List of currently supported sources](#list-of-currently-supported-sources)
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class RedditConnector(metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
log_path = Path(self.args.log).resolve().expanduser()
|
log_path = Path(self.args.log).resolve().expanduser()
|
||||||
if not log_path.parent.exists():
|
if not log_path.parent.exists():
|
||||||
raise errors.BulkDownloaderException(f"Designated location for logfile does not exist")
|
raise errors.BulkDownloaderException("Designated location for logfile does not exist")
|
||||||
backup_count = self.cfg_parser.getint("DEFAULT", "backup_log_count", fallback=3)
|
backup_count = self.cfg_parser.getint("DEFAULT", "backup_log_count", fallback=3)
|
||||||
file_handler = logging.handlers.RotatingFileHandler(
|
file_handler = logging.handlers.RotatingFileHandler(
|
||||||
log_path,
|
log_path,
|
||||||
@@ -323,7 +323,7 @@ class RedditConnector(metaclass=ABCMeta):
|
|||||||
def get_multireddits(self) -> list[Iterator]:
|
def get_multireddits(self) -> list[Iterator]:
|
||||||
if self.args.multireddit:
|
if self.args.multireddit:
|
||||||
if len(self.args.user) != 1:
|
if len(self.args.user) != 1:
|
||||||
logger.error(f"Only 1 user can be supplied when retrieving from multireddits")
|
logger.error("Only 1 user can be supplied when retrieving from multireddits")
|
||||||
return []
|
return []
|
||||||
out = []
|
out = []
|
||||||
for multi in self.split_args_input(self.args.multireddit):
|
for multi in self.split_args_input(self.args.multireddit):
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Imgur(BaseDownloader):
|
|||||||
image_dict = re.search(outer_regex, chosen_script).group(1)
|
image_dict = re.search(outer_regex, chosen_script).group(1)
|
||||||
image_dict = re.search(inner_regex, image_dict).group(1)
|
image_dict = re.search(inner_regex, image_dict).group(1)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise SiteDownloaderError(f"Could not find image dictionary in page source")
|
raise SiteDownloaderError("Could not find image dictionary in page source")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image_dict = json.loads(image_dict)
|
image_dict = json.loads(image_dict)
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
from typing import Optional
|
||||||
from pathlib import Path
|
|
||||||
from typing import Callable, Optional
|
|
||||||
|
|
||||||
import yt_dlp
|
|
||||||
from praw.models import Submission
|
from praw.models import Submission
|
||||||
|
|
||||||
from bdfr.exceptions import NotADownloadableLinkError, SiteDownloaderError
|
from bdfr.exceptions import NotADownloadableLinkError
|
||||||
from bdfr.resource import Resource
|
from bdfr.resource import Resource
|
||||||
from bdfr.site_authenticator import SiteAuthenticator
|
from bdfr.site_authenticator import SiteAuthenticator
|
||||||
from bdfr.site_downloaders.youtube import Youtube
|
from bdfr.site_downloaders.youtube import Youtube
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ bdfr-download = "bdfr.__main__:cli_download"
|
|||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
|
|
||||||
|
[tool.flake8]
|
||||||
|
exclude = ["scripts"]
|
||||||
|
max-line-length = 120
|
||||||
|
show-source = true
|
||||||
|
statistics = true
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
profile = "black"
|
profile = "black"
|
||||||
py_version = 39
|
py_version = 39
|
||||||
|
|||||||
@@ -76,4 +76,4 @@ def test_filter_empty_filter(test_url: str):
|
|||||||
download_filter = DownloadFilter()
|
download_filter = DownloadFilter()
|
||||||
test_resource = Resource(MagicMock(), test_url, lambda: None)
|
test_resource = Resource(MagicMock(), test_url, lambda: None)
|
||||||
result = download_filter.check_resource(test_resource)
|
result = download_filter.check_resource(test_resource)
|
||||||
assert result is True
|
assert result
|
||||||
|
|||||||
Reference in New Issue
Block a user