Skip to content

Commit 4389364

Browse files
committed
simple snack suggestion
1 parent b1b2427 commit 4389364

File tree

3 files changed

+81
-6
lines changed

3 files changed

+81
-6
lines changed

learning/snack_suggestions.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Check and provide snack if available else ask user to pick something else from menu"""
2+
3+
from __future__ import annotations
4+
5+
import logging
6+
import sys
7+
8+
logger = logging.getLogger(__name__)
9+
10+
# Define available snacks as a constant
11+
AVAILABLE_SNACKS = {"pizza", "pasta"}
12+
13+
14+
def get_user_input() -> str:
15+
"""Get user input from console.
16+
17+
Returns:
18+
str: User input in lowercase, or 'error' if invalid
19+
"""
20+
try:
21+
user_input = input("\nPlease provide your choice of snack: ")
22+
# Better validation - check if input is not empty after stripping
23+
cleaned_input = user_input.strip()
24+
return cleaned_input.lower() if cleaned_input else "error"
25+
except KeyboardInterrupt:
26+
logger.info("\nGoodbye!")
27+
sys.exit(0)
28+
except EOFError:
29+
logger.info("\nNo input received. Exiting...")
30+
sys.exit(0)
31+
32+
33+
def is_snack_available(snack: str) -> bool:
34+
"""Check if the requested snack is available.
35+
36+
Args:
37+
snack: The snack to check
38+
39+
Returns:
40+
bool: True if snack is available, False otherwise
41+
"""
42+
return snack in AVAILABLE_SNACKS
43+
44+
45+
def main():
46+
"""Main function to run the snack selector."""
47+
logging.basicConfig(
48+
level=logging.INFO,
49+
format="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s:%(lineno)d - %(message)s",
50+
datefmt="%Y-%m-%d %H:%M:%S",
51+
)
52+
53+
user_input = get_user_input()
54+
55+
if user_input == "error":
56+
logger.error("Invalid input provided. Exiting...")
57+
sys.exit(1) # Use exit code 1 for error
58+
elif is_snack_available(user_input):
59+
logger.info("Here you go %s", user_input)
60+
else:
61+
logger.info("Sorry, we don't have %s in our menu. Please try something else.", user_input)
62+
63+
64+
if __name__ == "__main__":
65+
main()

pyproject.toml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ dev = [
2626

2727
[tool.pyright]
2828
exclude = [".venv", "build", "dist"]
29-
pythonVersion = "3.10"
29+
pythonVersion = "3.13"
3030
venvPath = "."
3131
venv = ".venv"
3232
# Enhanced type checking for GenAI projects
33-
typeCheckingMode = "basic" # Can upgrade to "strict" as team matures
33+
typeCheckingMode = "strict" # Can upgrade to "strict" as team matures
3434
reportMissingImports = true
3535
reportMissingTypeStubs = false
3636
reportOptionalMemberAccess = true
@@ -41,12 +41,14 @@ reportUnusedVariable = true
4141
# AI / ML-specific settings
4242
reportIncompatibleMethodOverride = true
4343
reportIncompatibleVariableOverride = true
44+
autoImportCompletions = true
45+
autoSearchPaths = true
4446

4547
[tool.mypy]
46-
python_version = "3.10"
48+
python_version = "3.13"
4749
warn_return_any = true
4850
warn_unused_configs = true
49-
disallow_untyped_defs = false # Start permissive, can tighten later
51+
disallow_untyped_defs = true # Start permissive, can tighten later
5052
disallow_incomplete_defs = true
5153
check_untyped_defs = true
5254
disallow_untyped_decorators = false # Many AI libraries use untyped decorators
@@ -127,7 +129,8 @@ exclude = [
127129
# Code formatting
128130
line-length = 120
129131
indent-width = 4
130-
target-version = "py310"
132+
target-version = "py313"
133+
cache-dir = ".ruff_cache"
131134

132135
# CLI usage examples:
133136
# uv run ruff check . --fix --show-fixes --show-files
@@ -595,3 +598,10 @@ hardcoded_tmp_directory_extensions = ["tmp", "temp", "cache"]
595598
# Additional bandit configuration for GenAI projects
596599
[tool.bandit.assert_used]
597600
skips = ["*/test_*.py", "*/tests/*", "*_test.py"]
601+
602+
[build-system]
603+
requires = ["setuptools>=61.0", "wheel"]
604+
build-backend = "setuptools.build_meta"
605+
606+
[project.scripts]
607+
genai = "full_stack_gen_ai.cli:main"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)