Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Pylance typing" due to Python incompatibility #706

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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