diff --git a/python/mecha-munch-management/.coverage.xml b/python/mecha-munch-management/.coverage.xml index aca3460f..d4fcb505 100644 --- a/python/mecha-munch-management/.coverage.xml +++ b/python/mecha-munch-management/.coverage.xml @@ -1,5 +1,5 @@ - + diff --git a/python/mecha-munch-management/dict_methods.py b/python/mecha-munch-management/dict_methods.py index c1044ba1..ce41d1ab 100644 --- a/python/mecha-munch-management/dict_methods.py +++ b/python/mecha-munch-management/dict_methods.py @@ -1,22 +1,22 @@ """Functions to manage a users shopping cart items.""" # runners are still using py 3.11, can't use 3.12 type definitions -name_t = str -quantity_t = int -cart_t = dict[name_t, quantity_t] -items_t = list[name_t] | tuple[name_t] -recipes_t = dict[name_t, cart_t] -update_t = tuple[name_t, cart_t] -updates_t = list[update_t] | tuple[update_t] -refrigirate_t = bool -aisle_t = list[name_t | refrigirate_t] -aisle_map_t = dict[name_t, aisle_t] -inventory_entry_t = list[quantity_t | name_t | refrigirate_t] -fufillment_t = dict[name_t, inventory_entry_t] -message_t = str - - -def add_item(current_cart: cart_t, items_to_add: items_t) -> cart_t: +NameT = str +QuantityT = int +CartT = dict[NameT, QuantityT] +ItemsT = list[NameT] | tuple[NameT] +RecipesT = dict[NameT, CartT] +UpdateT = tuple[NameT, CartT] +UpdatesT = list[UpdateT] | tuple[UpdateT] +RefrigirateT = bool +AisleT = list[NameT | RefrigirateT] +AisleMapT = dict[NameT, AisleT] +InventoryEntryT = list[QuantityT | NameT | RefrigirateT] +FufillmentT = dict[NameT, InventoryEntryT] +MessageT = str + + +def add_item(current_cart: CartT, items_to_add: ItemsT) -> CartT: """Add items to shopping cart. :param current_cart: dict - the current shopping cart. @@ -31,19 +31,19 @@ def add_item(current_cart: cart_t, items_to_add: items_t) -> cart_t: return current_cart -def read_notes(notes: items_t) -> cart_t: +def read_notes(notes: ItemsT) -> CartT: """Create user cart from an iterable notes entry. :param notes: iterable of items to add to cart. :return: dict - a user shopping cart dictionary. """ - cart: cart_t = {} + cart: CartT = {} return add_item(cart, notes) -def update_recipes(ideas: recipes_t, recipe_updates: updates_t) -> recipes_t: +def update_recipes(ideas: RecipesT, recipe_updates: UpdatesT) -> RecipesT: """Update the recipe ideas dictionary. Replaces the existing list of items with a new list, don't update/merge. :param ideas: dict - The "recipe ideas" dict. @@ -51,11 +51,11 @@ def update_recipes(ideas: recipes_t, recipe_updates: updates_t) -> recipes_t: :return: dict - updated "recipe ideas" dict. """ - update: update_t + update: UpdateT for update in recipe_updates: - recipe_name: name_t = update[0] - items: cart_t = update[1] + recipe_name: NameT = update[0] + items: CartT = update[1] _ = ideas.setdefault(recipe_name, {}) @@ -64,7 +64,7 @@ def update_recipes(ideas: recipes_t, recipe_updates: updates_t) -> recipes_t: return ideas -def sort_entries(cart: cart_t) -> cart_t: +def sort_entries(cart: CartT) -> CartT: """Sort a users shopping cart in alphabetically order. :param cart: dict - a users shopping cart dictionary. @@ -74,7 +74,7 @@ def sort_entries(cart: cart_t) -> cart_t: return dict(sorted(cart.items())) -def send_to_store(cart: cart_t, aisle_mapping) -> fufillment_t: +def send_to_store(cart: CartT, aisle_mapping) -> FufillmentT: """Combine users order to aisle and refrigeration information. :param cart: dict - users shopping cart dictionary. @@ -82,11 +82,11 @@ def send_to_store(cart: cart_t, aisle_mapping) -> fufillment_t: :return: dict - fulfillment dictionary ready to send to store. """ - fufillment: fufillment_t = {} + fufillment: FufillmentT = {} - item_name: name_t - item_quantity: quantity_t - aisle: aisle_t + item_name: NameT + item_quantity: QuantityT + aisle: AisleT for item_name, item_quantity in cart.items(): aisle = aisle_mapping.setdefault(item_name, ["Aisle 0", False]) @@ -96,8 +96,8 @@ def send_to_store(cart: cart_t, aisle_mapping) -> fufillment_t: def update_store_inventory( - fulfillment_cart: fufillment_t, store_inventory: fufillment_t -) -> fufillment_t: + fulfillment_cart: FufillmentT, store_inventory: FufillmentT +) -> FufillmentT: """Update store inventory levels with user order. :param fulfillment cart: dict - fulfillment cart to send to store. @@ -105,13 +105,13 @@ def update_store_inventory( :return: dict - store_inventory updated. """ - new_inventory: fufillment_t = store_inventory.copy() + new_inventory: FufillmentT = store_inventory.copy() - item_name: name_t - order_quantity: quantity_t - inventory_quantity: quantity_t - new_quantity: quantity_t | message_t - data: inventory_entry_t + item_name: NameT + order_quantity: QuantityT + inventory_quantity: QuantityT + new_quantity: QuantityT | MessageT + data: InventoryEntryT for item_name in fulfillment_cart: order_quantity = int( diff --git a/python/mecha-munch-management/dict_methods.py,cover b/python/mecha-munch-management/dict_methods.py,cover index 102c8542..ebb6b9c6 100644 --- a/python/mecha-munch-management/dict_methods.py,cover +++ b/python/mecha-munch-management/dict_methods.py,cover @@ -1,22 +1,22 @@ > """Functions to manage a users shopping cart items.""" # runners are still using py 3.11, can't use 3.12 type definitions -> name_t = str -> quantity_t = int -> cart_t = dict[name_t, quantity_t] -> items_t = list[name_t] | tuple[name_t] -> recipes_t = dict[name_t, cart_t] -> update_t = tuple[name_t, cart_t] -> updates_t = list[update_t] | tuple[update_t] -> refrigirate_t = bool -> aisle_t = list[name_t | refrigirate_t] -> aisle_map_t = dict[name_t, aisle_t] -> inventory_entry_t = list[quantity_t | name_t | refrigirate_t] -> fufillment_t = dict[name_t, inventory_entry_t] -> message_t = str - - -> def add_item(current_cart: cart_t, items_to_add: items_t) -> cart_t: +> NameT = str +> QuantityT = int +> CartT = dict[NameT, QuantityT] +> ItemsT = list[NameT] | tuple[NameT] +> RecipesT = dict[NameT, CartT] +> UpdateT = tuple[NameT, CartT] +> UpdatesT = list[UpdateT] | tuple[UpdateT] +> RefrigirateT = bool +> AisleT = list[NameT | RefrigirateT] +> AisleMapT = dict[NameT, AisleT] +> InventoryEntryT = list[QuantityT | NameT | RefrigirateT] +> FufillmentT = dict[NameT, InventoryEntryT] +> MessageT = str + + +> def add_item(current_cart: CartT, items_to_add: ItemsT) -> CartT: > """Add items to shopping cart. > :param current_cart: dict - the current shopping cart. @@ -31,19 +31,19 @@ > return current_cart -> def read_notes(notes: items_t) -> cart_t: +> def read_notes(notes: ItemsT) -> CartT: > """Create user cart from an iterable notes entry. > :param notes: iterable of items to add to cart. > :return: dict - a user shopping cart dictionary. > """ -> cart: cart_t = {} +> cart: CartT = {} > return add_item(cart, notes) -> def update_recipes(ideas: recipes_t, recipe_updates: updates_t) -> recipes_t: +> def update_recipes(ideas: RecipesT, recipe_updates: UpdatesT) -> RecipesT: > """Update the recipe ideas dictionary. Replaces the existing list of items with a new list, don't update/merge. > :param ideas: dict - The "recipe ideas" dict. @@ -51,11 +51,11 @@ > :return: dict - updated "recipe ideas" dict. > """ -> update: update_t +> update: UpdateT > for update in recipe_updates: -> recipe_name: name_t = update[0] -> items: cart_t = update[1] +> recipe_name: NameT = update[0] +> items: CartT = update[1] > _ = ideas.setdefault(recipe_name, {}) @@ -64,7 +64,7 @@ > return ideas -> def sort_entries(cart: cart_t) -> cart_t: +> def sort_entries(cart: CartT) -> CartT: > """Sort a users shopping cart in alphabetically order. > :param cart: dict - a users shopping cart dictionary. @@ -74,7 +74,7 @@ > return dict(sorted(cart.items())) -> def send_to_store(cart: cart_t, aisle_mapping) -> fufillment_t: +> def send_to_store(cart: CartT, aisle_mapping) -> FufillmentT: > """Combine users order to aisle and refrigeration information. > :param cart: dict - users shopping cart dictionary. @@ -82,11 +82,11 @@ > :return: dict - fulfillment dictionary ready to send to store. > """ -> fufillment: fufillment_t = {} +> fufillment: FufillmentT = {} -> item_name: name_t -> item_quantity: quantity_t -> aisle: aisle_t +> item_name: NameT +> item_quantity: QuantityT +> aisle: AisleT > for item_name, item_quantity in cart.items(): > aisle = aisle_mapping.setdefault(item_name, ["Aisle 0", False]) @@ -96,8 +96,8 @@ > def update_store_inventory( -> fulfillment_cart: fufillment_t, store_inventory: fufillment_t -> ) -> fufillment_t: +> fulfillment_cart: FufillmentT, store_inventory: FufillmentT +> ) -> FufillmentT: > """Update store inventory levels with user order. > :param fulfillment cart: dict - fulfillment cart to send to store. @@ -105,13 +105,13 @@ > :return: dict - store_inventory updated. > """ -> new_inventory: fufillment_t = store_inventory.copy() +> new_inventory: FufillmentT = store_inventory.copy() -> item_name: name_t -> order_quantity: quantity_t -> inventory_quantity: quantity_t -> new_quantity: quantity_t | message_t -> data: inventory_entry_t +> item_name: NameT +> order_quantity: QuantityT +> inventory_quantity: QuantityT +> new_quantity: QuantityT | MessageT +> data: InventoryEntryT > for item_name in fulfillment_cart: > order_quantity = int( diff --git a/python/mecha-munch-management/run-tests-python.txt b/python/mecha-munch-management/run-tests-python.txt index 80c6d239..2dd3d946 100644 --- a/python/mecha-munch-management/run-tests-python.txt +++ b/python/mecha-munch-management/run-tests-python.txt @@ -23,48 +23,36 @@ pylint 3.0.3 astroid 3.0.2 Python 3.12.1 (main, Dec 28 2023, 08:22:05) [GCC 10.2.1 20210110] -real 0m0.244s -user 0m0.172s -sys 0m0.074s +real 0m0.223s +user 0m0.154s +sys 0m0.071s ============================================================================== Running: pylint ./src -************* Module mecha_munch_management.dict_methods -src/mecha_munch_management/dict_methods.py:4:0: C0103: Class name "name_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:5:0: C0103: Class name "quantity_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:6:0: C0103: Class name "cart_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:8:0: C0103: Class name "recipes_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:9:0: C0103: Class name "update_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:11:0: C0103: Class name "refrigirate_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:12:0: C0103: Class name "aisle_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:13:0: C0103: Class name "aisle_map_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:14:0: C0103: Class name "inventory_entry_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:15:0: C0103: Class name "fufillment_t" doesn't conform to PascalCase naming style (invalid-name) -src/mecha_munch_management/dict_methods.py:16:0: C0103: Class name "message_t" doesn't conform to PascalCase naming style (invalid-name) ------------------------------------------------------------------- -Your code has been rated at 8.04/10 (previous run: 10.00/10, -1.96) +Your code has been rated at 10.00/10 (previous run: 9.82/10, +0.18) -real 0m0.435s -user 0m0.366s -sys 0m0.070s +real 0m0.431s +user 0m0.353s +sys 0m0.080s ============================================================================== -Exit code: -1 +Exit code: 0 -real 0m1.639s -user 0m1.206s -sys 0m0.457s +real 0m1.564s +user 0m1.139s +sys 0m0.446s -real 0m1.643s -user 0m1.209s -sys 0m0.458s +real 0m1.569s +user 0m1.141s +sys 0m0.448s =============================================================================== @@ -86,9 +74,9 @@ Running: ruff --version ruff 0.3.5 -real 0m0.064s -user 0m0.026s -sys 0m0.040s +real 0m0.086s +user 0m0.036s +sys 0m0.052s ============================================================================== @@ -97,22 +85,22 @@ Running: ruff check --ignore E501 ./src All checks passed! -real 0m0.111s -user 0m0.054s -sys 0m0.061s +real 0m0.116s +user 0m0.052s +sys 0m0.067s ============================================================================== Exit code: 0 -real 0m1.107s -user 0m0.756s -sys 0m0.373s +real 0m1.098s +user 0m0.726s +sys 0m0.395s -real 0m1.109s -user 0m0.757s -sys 0m0.374s +real 0m1.100s +user 0m0.726s +sys 0m0.397s =============================================================================== @@ -134,9 +122,9 @@ Running: pyright --version pyright 1.1.357 -real 0m1.021s -user 0m0.562s -sys 0m0.107s +real 0m0.902s +user 0m0.515s +sys 0m0.104s ============================================================================== @@ -146,7 +134,7 @@ Running: pyright --stats ./src Found 2 source files pyright 1.1.357 0 errors, 0 warnings, 0 informations -Completed in 0.601sec +Completed in 0.608sec Analysis stats Total files parsed and bound: 20 @@ -154,30 +142,30 @@ Total files checked: 2 Timing stats Find Source Files: 0sec -Read Source Files: 0.01sec -Tokenize: 0.03sec +Read Source Files: 0sec +Tokenize: 0.04sec Parse: 0.04sec Resolve Imports: 0.04sec -Bind: 0.04sec +Bind: 0.05sec Check: 0.12sec Detect Cycles: 0sec -real 0m1.252s -user 0m1.194s -sys 0m0.164s +real 0m1.245s +user 0m1.229s +sys 0m0.167s ============================================================================== Exit code: 0 -real 0m3.245s -user 0m2.444s -sys 0m0.572s +real 0m3.067s +user 0m2.403s +sys 0m0.547s -real 0m3.248s -user 0m2.444s -sys 0m0.575s +real 0m3.069s +user 0m2.405s +sys 0m0.547s =============================================================================== @@ -200,9 +188,9 @@ Running: bandit --version bandit 1.7.7 python version = 3.12.1 (main, Dec 28 2023, 08:22:05) [GCC 10.2.1 20210110] -real 0m0.287s -user 0m0.231s -sys 0m0.059s +real 0m0.227s +user 0m0.149s +sys 0m0.080s ============================================================================== @@ -214,7 +202,7 @@ Running: bandit --verbose --recursive ./src [main] INFO cli include tests: None [main] INFO cli exclude tests: None [main] INFO running on Python 3.12.1 -Run started:2024-04-04 05:13:31.991645 +Run started:2024-04-04 05:25:00.790930 Files in scope (2): ./src/mecha_munch_management/__init__.py (score: {SEVERITY: 0, CONFIDENCE: 0}) ./src/mecha_munch_management/dict_methods.py (score: {SEVERITY: 0, CONFIDENCE: 0}) @@ -243,9 +231,9 @@ Run metrics: High: 0 Files skipped (0): -real 0m0.224s -user 0m0.161s -sys 0m0.065s +real 0m0.243s +user 0m0.174s +sys 0m0.072s ============================================================================== @@ -253,12 +241,12 @@ sys 0m0.065s Exit code: 0 real 0m1.405s -user 0m1.022s -sys 0m0.400s +user 0m0.979s +sys 0m0.446s -real 0m1.407s -user 0m1.024s -sys 0m0.400s +real 0m1.408s +user 0m0.979s +sys 0m0.448s =============================================================================== @@ -281,9 +269,9 @@ Running: refurb --version Refurb: v1.26.0 Mypy: v1.9.0 -real 0m0.198s -user 0m0.136s -sys 0m0.064s +real 0m0.180s +user 0m0.131s +sys 0m0.050s ============================================================================== @@ -291,22 +279,22 @@ sys 0m0.064s Running: refurb ./src -real 0m1.177s -user 0m1.087s -sys 0m0.092s +real 0m1.062s +user 0m0.980s +sys 0m0.083s ============================================================================== Exit code: 0 -real 0m2.285s -user 0m1.900s -sys 0m0.403s +real 0m2.157s +user 0m1.788s +sys 0m0.385s -real 0m2.287s -user 0m1.900s -sys 0m0.405s +real 0m2.160s +user 0m1.790s +sys 0m0.385s =============================================================================== @@ -347,22 +335,22 @@ Test passed. 0 passed and 0 failed. Test passed. -real 0m0.139s -user 0m0.089s -sys 0m0.052s +real 0m0.146s +user 0m0.078s +sys 0m0.071s ============================================================================== Exit code: 0 -real 0m1.060s -user 0m0.760s -sys 0m0.318s +real 0m1.064s +user 0m0.703s +sys 0m0.379s -real 0m1.062s -user 0m0.761s -sys 0m0.318s +real 0m1.066s +user 0m0.703s +sys 0m0.381s =============================================================================== @@ -394,9 +382,9 @@ Running: pytest --version pytest 7.4.3 -real 0m0.823s -user 0m0.888s -sys 0m0.825s +real 0m0.799s +user 0m0.868s +sys 0m0.792s ============================================================================== @@ -432,11 +420,11 @@ TOTAL 47 0 8 0 100% Coverage XML written to file .coverage.xml -============================== 6 passed in 0.45s =============================== +============================== 6 passed in 0.37s =============================== -real 0m1.358s -user 0m1.207s -sys 0m0.153s +real 0m1.170s +user 0m1.044s +sys 0m0.127s ============================================================================== @@ -449,9 +437,9 @@ dict_methods.py 47 0 8 0 100% ------------------------------------------------------------- TOTAL 47 0 8 0 100% -real 0m0.167s +real 0m0.173s user 0m0.112s -sys 0m0.057s +sys 0m0.063s ============================================================================== @@ -459,9 +447,9 @@ sys 0m0.057s Running: coverage annotate -real 0m0.144s -user 0m0.096s -sys 0m0.049s +real 0m0.160s +user 0m0.105s +sys 0m0.057s ============================================================================== @@ -473,48 +461,48 @@ Branch Coverage: 100.0% Exit code: 0 -real 0m3.878s -user 0m3.287s -sys 0m1.562s +real 0m3.666s +user 0m3.063s +sys 0m1.550s -real 0m3.880s -user 0m3.289s -sys 0m1.563s +real 0m3.668s +user 0m3.063s +sys 0m1.551s =============================================================================== tail -n 10000 ./*,cover | grep -E -C 3 '^> def |^! ' -> def add_item(current_cart: cart_t, items_to_add: items_t) -> cart_t: +> def add_item(current_cart: CartT, items_to_add: ItemsT) -> CartT: > """Add items to shopping cart. -- -> def read_notes(notes: items_t) -> cart_t: +> def read_notes(notes: ItemsT) -> CartT: > """Create user cart from an iterable notes entry. -- -> def update_recipes(ideas: recipes_t, recipe_updates: updates_t) -> recipes_t: +> def update_recipes(ideas: RecipesT, recipe_updates: UpdatesT) -> RecipesT: > """Update the recipe ideas dictionary. Replaces the existing list of items with a new list, don't update/merge. -- -> def sort_entries(cart: cart_t) -> cart_t: +> def sort_entries(cart: CartT) -> CartT: > """Sort a users shopping cart in alphabetically order. -- -> def send_to_store(cart: cart_t, aisle_mapping) -> fufillment_t: +> def send_to_store(cart: CartT, aisle_mapping) -> FufillmentT: > """Combine users order to aisle and refrigeration information. -- > def update_store_inventory( -> fulfillment_cart: fufillment_t, store_inventory: fufillment_t +> fulfillment_cart: FufillmentT, store_inventory: FufillmentT =============================================================================== Running: misspell ./src/mecha_munch_management/dict_methods.py ./src/mecha_munch_management/__init__.py -real 0m0.020s -user 0m0.019s -sys 0m0.007s +real 0m0.018s +user 0m0.016s +sys 0m0.010s ===============================================================================