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

Support for erailer Python < 3.10 (TypeError: unsupported operand type(s) for |: 'type' and 'NoneType') #22

Open
i3z0x1 opened this issue Apr 5, 2024 · 0 comments

Comments

@i3z0x1
Copy link

i3z0x1 commented Apr 5, 2024

For those who would like to run this great script with eariler version of python < 3.10

As major new features of the 3.10 series, compared to 3.9 and earlier

PEP 604 – Allow writing union types as X | Y

You need to wrap '|' to a string, therefore little change in the codebase and you can get this up and running.

Change bellow lines:

Replace

def __init__(self, url: str, password: str | None = None, max_workers: int = 5) -> None:

To

    def __init__(self, url: str, password: "str | None" = None, max_workers: int = 5) -> None:

Replace

self._downloaddir: str | None = getenv("GF_DOWNLOADDIR")

To

        self._downloaddir: "str | None" = getenv("GF_DOWNLOADDIR")

Replace

self._password: str | None = sha256(password.encode()).hexdigest() if password else None

To

        self._password: "str | None" = sha256(password.encode()).hexdigest() if password else None

Replace

has_size: str | None = None

To

        has_size: "str | None" = None

Replace

def _parseLinks(self, _id: str, token: str, password: str | None = None) -> None:

To

    def _parseLinks(self, _id: str, token: str, password: "str | None" = None) -> None:

Replace

url: str | None = None
password: str | None = None

To

        url: "str | None" = None
        password: "str | None" = None

Tested on Python 3.9.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant