Skip to content

Commit

Permalink
Merge pull request #706 from aliparlakci/revert-705-development
Browse files Browse the repository at this point in the history
  • Loading branch information
Serene-Arc authored Dec 1, 2022
2 parents d056647 + 45429be commit 3278e67
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bdfr/archive_entry/base_archive_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class BaseArchiveEntry(ABC):
def __init__(self, source: Comment | Submission):
def __init__(self, source: (Comment, Submission)):
self.source = source
self.post_details: dict = {}

Expand Down
4 changes: 2 additions & 2 deletions bdfr/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def get_user_data(self) -> list[Iterator]:
return results

@staticmethod
def _pull_lever_entry_factory(praw_item: praw.models.Submission | praw.models.Comment) -> BaseArchiveEntry:
def _pull_lever_entry_factory(praw_item: (praw.models.Submission, praw.models.Comment)) -> BaseArchiveEntry:
if isinstance(praw_item, praw.models.Submission):
return SubmissionArchiveEntry(praw_item)
elif isinstance(praw_item, praw.models.Comment):
return CommentArchiveEntry(praw_item)
else:
raise ArchiverError(f'Factory failed to classify item of type {type(praw_item).__name__}')

def write_entry(self, praw_item: praw.models.Submission | praw.models.Comment):
def write_entry(self, praw_item: (praw.models.Submission, praw.models.Comment)):
if self.args.comment_context and isinstance(praw_item, praw.models.Comment):
logger.debug(f'Converting comment {praw_item.id} to submission {praw_item.submission.id}')
praw_item = praw_item.submission
Expand Down
2 changes: 1 addition & 1 deletion bdfr/file_name_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, file_format_string: str, directory_format_string: str, time_f
self.directory_format_string: list[str] = directory_format_string.split('/')
self.time_format_string = time_format_string

def _format_name(self, submission: Comment | Submission, format_string: str) -> str:
def _format_name(self, submission: (Comment, Submission), format_string: str) -> str:
if isinstance(submission, Submission):
attributes = self._generate_name_dict_from_submission(submission)
elif isinstance(submission, Comment):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_file_name_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import unittest.mock
from datetime import datetime
from pathlib import Path
from typing import Optional, Type
from typing import Optional
from unittest.mock import MagicMock

import praw.models
Expand All @@ -33,7 +33,7 @@ def submission() -> MagicMock:
return test


def do_test_string_equality(result: Path | str, expected: str) -> bool:
def do_test_string_equality(result: [Path, str], expected: str) -> bool:
if platform.system() == 'Windows':
expected = FileNameFormatter._format_for_windows(expected)
return str(result).endswith(expected)
Expand Down Expand Up @@ -411,7 +411,7 @@ def test_windows_max_path(tmp_path: Path):
))
def test_name_submission(
test_reddit_id: str,
test_downloader: Type[BaseDownloader],
test_downloader: type(BaseDownloader),
expected_names: set[str],
reddit_instance: praw.reddit.Reddit,
):
Expand Down

0 comments on commit 3278e67

Please sign in to comment.