diff --git a/poetry.lock b/poetry.lock --- a/poetry.lock +++ b/poetry.lock @@ -206,10 +206,18 @@ brotli = ["brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] +[[package]] +name = "vermin" +version = "1.3.3" +description = "Concurrently detect the minimum Python versions needed to run code" +category = "dev" +optional = false +python-versions = ">=2.7" + [metadata] lock-version = "1.1" python-versions = "^3.10" -content-hash = "14f945aef88b635fa5d4cc1f329572834551d8fb4fe0c7cbbbcfa419bbec84a7" +content-hash = "e73abda5748e52a1074f136fa035a8e427d57dd92ba4983c81141974a97dc25e" [metadata.files] black = [ @@ -323,3 +331,6 @@ urllib3 = [ {file = "urllib3-1.26.8-py2.py3-none-any.whl", hash = "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed"}, {file = "urllib3-1.26.8.tar.gz", hash = "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"}, ] +vermin = [ + {file = "vermin-1.3.3-py2.py3-none-any.whl", hash = "sha256:c5bd8bf2026d87563332293a0479606954bd973d8cf72ab370e1164a019c0524"}, +] diff --git a/pyproject.toml b/pyproject.toml --- a/pyproject.toml +++ b/pyproject.toml @@ -14,6 +14,7 @@ rich = "^11.2.0" mypy = "^0.931" black = "^22.1.0" isort = "^5.10.1" +vermin = "^1.3.3" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/stockcli/stock.py b/stockcli/stock.py --- a/stockcli/stock.py +++ b/stockcli/stock.py @@ -1,6 +1,6 @@ import logging from operator import itemgetter -from typing import Any +from typing import Any, Dict, List from rich.panel import Panel from rich.table import Table @@ -12,16 +12,14 @@ from .style import GreenBoldText def get_info_by_barcode(barcode: str) -> None: - product = utils.get_request( - f"stock/products/by-barcode/{barcode}" - ) # type: dict[str, Any] + product = utils.get_request(f"stock/products/by-barcode/{barcode}") inner_product = product["product"] product_id = inner_product["id"] product_group = utils.get_request( f"objects/product_groups/{inner_product['product_group_id']}" - ) # type: dict[str, Any] + ) grid = Table.grid(padding=DEFAULT_PADDING) grid.add_column(justify="left", no_wrap=True) @@ -44,7 +42,7 @@ def get_info_by_barcode(barcode: str) -> purchase_to_stock_conversion = utils.get_request( f"objects/quantity_unit_conversions?query[]=from_qu_id={purchase_quantity_unit['id']}&query[]=to_qu_id={stock_quantity_unit['id']}" - ) # type: list[dict[str, Any]] + ) if len(purchase_to_stock_conversion) != 0: conversion = f"{purchase_to_stock_conversion[0]['factor']} {stock_quantity_unit['name_plural']}" @@ -66,9 +64,7 @@ def get_info_by_barcode(barcode: str) -> if stock_amount > 0: grid.add_row(GreenBoldText("Locations:")) - locations = utils.get_request( - f"stock/products/{product_id}/locations" - ) # type: list[dict[str, Any]] + locations = utils.get_request(f"stock/products/{product_id}/locations") for location in sorted(locations, key=itemgetter("location_name")): grid.add_row( @@ -83,17 +79,13 @@ def get_info_by_barcode(barcode: str) -> def transfer_by_barcode(barcode: str) -> None: - product = utils.get_request( - f"stock/products/by-barcode/{barcode}" - ) # type: dict[str, Any] + product = utils.get_request(f"stock/products/by-barcode/{barcode}") inner_product = product["product"] product_id = inner_product["id"] - locations = utils.get_request( - f"stock/products/{product_id}/locations" - ) # type: list[dict[str, Any]] - all_locations = utils.get_request("objects/locations") # type: list[dict[str, Any]] + locations = utils.get_request(f"stock/products/{product_id}/locations") + all_locations = utils.get_request("objects/locations") grid = Table.grid(padding=DEFAULT_PADDING) grid.add_column(justify="right", no_wrap=True) @@ -172,18 +164,14 @@ def transfer_by_barcode(barcode: str) -> data = {"amount": amount, "location_id_from": from_id, "location_id_to": to_id} - response = utils.post_request( - f"stock/products/by-barcode/{barcode}/transfer", data - ) # type: dict[str, Any] + response = utils.post_request(f"stock/products/by-barcode/{barcode}/transfer", data) console.print("Successfully transfered!") return def add_by_barcode(barcode: str) -> None: - product = utils.get_request( - f"stock/products/by-barcode/{barcode}" - ) # type: dict[str, Any] + product = utils.get_request(f"stock/products/by-barcode/{barcode}") inner_product = product["product"] product_id = inner_product["id"] @@ -209,18 +197,14 @@ def add_by_barcode(barcode: str) -> None data = {"amount": amount, "transaction_type": "purchase"} - response = utils.post_request( - f"stock/products/by-barcode/{barcode}/add", data - ) # type: dict[str, Any] + response = utils.post_request(f"stock/products/by-barcode/{barcode}/add", data) console.print("Successfully added!") return def update_by_barcode(barcode: str) -> None: - product = utils.get_request( - f"stock/products/by-barcode/{barcode}" - ) # type: dict[str, Any] + product = utils.get_request(f"stock/products/by-barcode/{barcode}") inner_product = product["product"] product_id = inner_product["id"] @@ -250,8 +234,6 @@ def update_by_barcode(barcode: str) -> N "new_amount": amount, } - response = utils.post_request( - f"stock/products/{product_id}/inventory", data - ) # type: dict[str, Any] + response = utils.post_request(f"stock/products/{product_id}/inventory", data) console.print("Successfully updated!") return