Skip to content

Commit b1b2427

Browse files
committed
first script
1 parent aba5d3d commit b1b2427

File tree

10 files changed

+591
-46
lines changed

10 files changed

+591
-46
lines changed

.coverage

52 KB
Binary file not shown.

.secrets.baseline

Lines changed: 495 additions & 6 deletions
Large diffs are not rendered by default.

coverage.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" ?>
2+
<coverage version="7.10.7" timestamp="1759061744039" lines-valid="3" lines-covered="0" line-rate="0" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
3+
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.10.7 -->
4+
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
5+
<sources>
6+
<source>/Users/tejaspancholi/Developer/python/udemy/full_stack_gen_ai_with_python</source>
7+
</sources>
8+
<packages>
9+
<package name="." line-rate="0" branch-rate="0" complexity="0">
10+
<classes>
11+
<class name="main.py" filename="main.py" complexity="0" line-rate="0" branch-rate="0">
12+
<methods/>
13+
<lines>
14+
<line number="1" hits="0"/>
15+
<line number="4" hits="0"/>
16+
<line number="5" hits="0"/>
17+
</lines>
18+
</class>
19+
</classes>
20+
</package>
21+
</packages>
22+
</coverage>

learning/__init__.py

Whitespace-only changes.

learning/kettle_boiling.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Simple function to log if the kettle is boiling or not."""
2+
3+
from __future__ import annotations
4+
5+
import logging
6+
import random
7+
8+
logger = logging.getLogger(__name__)
9+
10+
11+
def kettle_boiling_notification(*, is_kettle_boiled: bool):
12+
"""A simple function that logs if the kettle is boiled or not.
13+
Args:
14+
is_kettle_boiled (boolean): status of kettle boiling
15+
Returns:
16+
None
17+
Raises:
18+
None
19+
"""
20+
if is_kettle_boiled:
21+
logger.info("Kettle Done! time to make Chai")
22+
else:
23+
logger.info("Kettle Not Done! wait for some more time.")
24+
25+
26+
def main():
27+
# Configure logging so INFO messages are printed to the console
28+
logging.basicConfig(
29+
level=logging.INFO,
30+
format="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s:%(lineno)d - %(message)s",
31+
datefmt="%Y-%m-%d %H:%M:%S",
32+
)
33+
kettle_boiled = bool(random.getrandbits(1))
34+
kettle_boiling_notification(is_kettle_boiled=kettle_boiled)
35+
36+
37+
if __name__ == "__main__":
38+
main()

main.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

pyproject.toml

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

2727
[tool.pyright]
2828
exclude = [".venv", "build", "dist"]
29-
pythonVersion = "3.13"
29+
pythonVersion = "3.10"
3030
venvPath = "."
3131
venv = ".venv"
3232
# Enhanced type checking for GenAI projects
@@ -43,7 +43,7 @@ reportIncompatibleMethodOverride = true
4343
reportIncompatibleVariableOverride = true
4444

4545
[tool.mypy]
46-
python_version = "3.13"
46+
python_version = "3.10"
4747
warn_return_any = true
4848
warn_unused_configs = true
4949
disallow_untyped_defs = false # Start permissive, can tighten later
@@ -125,9 +125,9 @@ exclude = [
125125
]
126126

127127
# Code formatting
128-
line-length = 88
128+
line-length = 120
129129
indent-width = 4
130-
target-version = "py313"
130+
target-version = "py310"
131131

132132
# CLI usage examples:
133133
# uv run ruff check . --fix --show-fixes --show-files
@@ -492,7 +492,7 @@ staticmethod-decorators = ["staticmethod"]
492492
[tool.ruff.lint.pycodestyle]
493493
# Line length settings
494494
ignore-overlong-task-comments = true
495-
max-doc-length = 88
495+
max-doc-length = 120
496496

497497
[tool.ruff.lint.pydocstyle]
498498
# Docstring style (Google style)

scripts/dev.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from __future__ import annotations
2222

2323
import argparse
24+
import shutil
2425
import subprocess
2526
import sys
2627
from pathlib import Path
@@ -51,13 +52,14 @@ def __init__(self) -> None:
5152
def _has_uv(self) -> bool:
5253
"""Check if uv is available."""
5354
try:
54-
subprocess.run(["uv", "--version"], capture_output=True, check=True)
55-
return True
55+
subprocess.run(["uv", "--version"], capture_output=True, check=True) # noqa: S607
56+
return True # noqa: TRY300
5657
except (subprocess.CalledProcessError, FileNotFoundError):
5758
return False
5859

5960
def _run_command(
6061
self,
62+
*,
6163
command: str,
6264
description: str,
6365
check: bool = True,
@@ -77,18 +79,12 @@ def _run_command(
7779
capture_output=False,
7880
)
7981
if result.returncode == 0:
80-
print(
81-
f"{Colors.GREEN}{description} completed successfully{Colors.END}"
82-
)
82+
print(f"{Colors.GREEN}{description} completed successfully{Colors.END}")
8383
else:
84-
print(
85-
f"{Colors.YELLOW}⚠️ {description} completed with warnings{Colors.END}"
86-
)
87-
return result
84+
print(f"{Colors.YELLOW}⚠️ {description} completed with warnings{Colors.END}")
85+
return result # noqa: TRY300
8886
except subprocess.CalledProcessError as e:
89-
print(
90-
f"{Colors.RED}{description} failed with exit code {e.returncode}{Colors.END}"
91-
)
87+
print(f"{Colors.RED}{description} failed with exit code {e.returncode}{Colors.END}")
9288
if check:
9389
raise
9490
return e
@@ -105,23 +101,19 @@ def setup(self) -> None:
105101

106102
# Install dependencies
107103
if self._has_uv():
108-
self._run_command("uv sync --dev", "Installing dependencies with uv")
104+
self._run_command(command="uv sync --dev", description="Installing dependencies with uv")
109105
else:
110-
self._run_command(
111-
"pip install -e .", "Installing project in development mode"
112-
)
106+
self._run_command(command="pip install -e .", description="Installing project in development mode")
113107

114108
# Setup pre-commit
115-
self._run_command(
116-
f"{self.python_cmd} pre-commit install", "Installing pre-commit hooks"
117-
)
109+
self._run_command(command=f"{self.python_cmd} pre-commit install", description="Installing pre-commit hooks")
118110

119111
# Initialize secrets baseline
120112
secrets_baseline = self.root_dir / ".secrets.baseline"
121113
if not secrets_baseline.exists():
122114
self._run_command(
123-
f"{self.python_cmd} detect-secrets scan --baseline .secrets.baseline",
124-
"Creating secrets detection baseline",
115+
command=f"{self.python_cmd} detect-secrets scan --baseline .secrets.baseline",
116+
description="Creating secrets detection baseline",
125117
)
126118

127119
# Create necessary directories
@@ -243,8 +235,6 @@ def clean(self) -> None:
243235
"""Clean up temporary files."""
244236
self._print_header("Cleaning Temporary Files")
245237

246-
import shutil
247-
248238
cleanup_patterns = [
249239
"**/__pycache__",
250240
"**/*.pyc",
@@ -324,9 +314,7 @@ def update(self) -> None:
324314
self._print_header("Updating Dependencies")
325315

326316
if self._has_uv():
327-
self._run_command(
328-
"uv sync --dev --upgrade", "Updating dependencies with uv"
329-
)
317+
self._run_command("uv sync --dev --upgrade", "Updating dependencies with uv")
330318
else:
331319
self._run_command("pip install --upgrade -e .[dev]", "Updating with pip")
332320

@@ -338,9 +326,7 @@ def main() -> NoReturn:
338326
"""Main entry point."""
339327
workflow = DevWorkflow()
340328

341-
parser = argparse.ArgumentParser(
342-
description="Development workflow automation for GenAI Python projects"
343-
)
329+
parser = argparse.ArgumentParser(description="Development workflow automation for GenAI Python projects")
344330
parser.add_argument(
345331
"command",
346332
choices=[

tests/__init__.py

Whitespace-only changes.

tests/test_basic.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Basic test to ensure testing setup works."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
7+
8+
def test_basic():
9+
"""Basic test that always passes."""
10+
assert True
11+
12+
13+
def test_imports():
14+
"""Test that we can import common libraries."""
15+
16+
assert sys.version_info >= (3, 13)

0 commit comments

Comments
 (0)