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

Probable fix for #535 - use union instead of | operator for python 3.9 compatibility #540

Merged
merged 2 commits into from
Sep 20, 2024
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
3 changes: 2 additions & 1 deletion lcsc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io
from pathlib import Path
from typing import Union

import requests # pylint: disable=import-error

Expand Down Expand Up @@ -31,7 +32,7 @@ def get_part_data(self, lcsc_number: str) -> dict:
}
return {"success": True, "data": data}

def download_bitmap(self, url: str) -> io.BytesIO | None:
def download_bitmap(self, url: str) -> Union[io.BytesIO, None]:
"""Download a picture of the part from the API."""
content = requests.get(url, headers=self.headers, timeout=10).content
return io.BytesIO(content)
Expand Down
3 changes: 2 additions & 1 deletion store.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
from pathlib import Path
import sqlite3
from typing import Union

from .helpers import (
dict_factory,
Expand Down Expand Up @@ -131,7 +132,7 @@ def get_part(self, ref: str) -> dict:
{"reference": ref},
).fetchone()

def set_stock(self, ref: str, stock: int | None):
def set_stock(self, ref: str, stock: Union[int, None]):
"""Set the stock value for a part in the database."""
with contextlib.closing(sqlite3.connect(self.dbfile)) as con, con as cur:
cur.execute(
Expand Down