Changeset - 8c86d58fda4b
[Not reviewed]
default
0 3 0
Dennis Fink - 3 years ago 2022-03-03 17:55:27
dennis.fink@c3l.lu
Remove uneeded type annotations
3 files changed with 26 insertions and 32 deletions:
0 comments (0 inline, 0 general)
poetry.lock
Show inline comments
 
@@ -203,16 +203,24 @@ python-versions = ">=2.7, !=3.0.*, !=3.1
 

	
 
[package.extras]
 
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 = [
 
    {file = "black-22.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1297c63b9e1b96a3d0da2d85d11cd9bf8664251fd69ddac068b98dc4f34f73b6"},
 
    {file = "black-22.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2ff96450d3ad9ea499fc4c60e425a1439c2120cbbc1ab959ff20f7c76ec7e866"},
 
    {file = "black-22.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e21e1f1efa65a50e3960edd068b6ae6d64ad6235bd8bfea116a03b21836af71"},
 
@@ -320,6 +328,9 @@ typing-extensions = [
 
    {file = "typing_extensions-4.0.1.tar.gz", hash = "sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e"},
 
]
 
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"},
 
]
pyproject.toml
Show inline comments
 
@@ -11,10 +11,11 @@ click = "^8.0.3"
 
rich = "^11.2.0"
 

	
 
[tool.poetry.dev-dependencies]
 
mypy = "^0.931"
 
black = "^22.1.0"
 
isort = "^5.10.1"
 
vermin = "^1.3.3"
 

	
 
[build-system]
 
requires = ["poetry-core>=1.0.0"]
 
build-backend = "poetry.core.masonry.api"
stockcli/stock.py
Show inline comments
 
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
 

	
 
from . import utils
 
from .console import DEFAULT_PADDING, console, int_prompt, prompt
 
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)
 
    grid.add_column(justify="right", style="cyan", no_wrap=True)
 
    grid.add_column(justify="left", no_wrap=True)
 

	
 
@@ -41,13 +39,13 @@ def get_info_by_barcode(barcode: str) ->
 

	
 
    purchase_quantity_unit = product["default_quantity_unit_purchase"]
 
    stock_quantity_unit = product["quantity_unit_stock"]
 

	
 
    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']}"
 
    else:
 
        conversion = ""
 

	
 
@@ -63,15 +61,13 @@ def get_info_by_barcode(barcode: str) ->
 

	
 
    stock_amount = int(product["stock_amount"])
 
    grid.add_row(GreenBoldText("Overall Stock Amount:"), str(stock_amount))
 

	
 
    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(
 
                f"[green bold]-[/green bold] [magenta]{location['location_name']}[/magenta]",
 
                location["amount"],
 
            )
 
@@ -80,23 +76,19 @@ def get_info_by_barcode(barcode: str) ->
 

	
 
    return
 

	
 

	
 
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)
 
    grid.add_column(justify="left", style="cyan", no_wrap=True)
 
    grid.add_column(justify="right", style="magenta", no_wrap=True)
 

	
 
@@ -169,24 +161,20 @@ def transfer_by_barcode(barcode: str) ->
 
    if not amount:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    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"]
 

	
 
    grid = Table.grid(padding=DEFAULT_PADDING)
 
    grid.add_column(justify="right", no_wrap=True)
 
@@ -206,24 +194,20 @@ def add_by_barcode(barcode: str) -> None
 
    if not amount:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    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"]
 

	
 
    grid = Table.grid(padding=DEFAULT_PADDING)
 
    grid.add_column(justify="right", no_wrap=True)
 
@@ -247,11 +231,9 @@ def update_by_barcode(barcode: str) -> N
 
        return
 

	
 
    data = {
 
        "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
0 comments (0 inline, 0 general)