Spaces:
Sleeping
Sleeping
Commit
·
0031f83
0
Parent(s):
Initial project structure
Browse files- .gitignore +93 -0
- .python-version +1 -0
- README.md +59 -0
- pyproject.toml +30 -0
- src/demo_application/__init__.py +3 -0
- src/demo_application/main.py +6 -0
- tests/__init__.py +0 -0
- tests/test_main.py +12 -0
.gitignore
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
|
| 6 |
+
# C extensions
|
| 7 |
+
*.so
|
| 8 |
+
|
| 9 |
+
# Distribution / packaging
|
| 10 |
+
.Python
|
| 11 |
+
build/
|
| 12 |
+
develop-eggs/
|
| 13 |
+
dist/
|
| 14 |
+
downloads/
|
| 15 |
+
eggs/
|
| 16 |
+
.eggs/
|
| 17 |
+
lib/
|
| 18 |
+
lib64/
|
| 19 |
+
parts/
|
| 20 |
+
sdist/
|
| 21 |
+
var/
|
| 22 |
+
wheels/
|
| 23 |
+
share/python-wheels/
|
| 24 |
+
*.egg-info/
|
| 25 |
+
.installed.cfg
|
| 26 |
+
*.egg
|
| 27 |
+
MANIFEST
|
| 28 |
+
|
| 29 |
+
# Virtual environments
|
| 30 |
+
.env
|
| 31 |
+
.venv/
|
| 32 |
+
env/
|
| 33 |
+
venv/
|
| 34 |
+
ENV/
|
| 35 |
+
env.bak/
|
| 36 |
+
venv.bak/
|
| 37 |
+
|
| 38 |
+
# IDEs and editors
|
| 39 |
+
.vscode/
|
| 40 |
+
.idea/
|
| 41 |
+
*.swp
|
| 42 |
+
*.swo
|
| 43 |
+
*~
|
| 44 |
+
.ropeproject/
|
| 45 |
+
|
| 46 |
+
# OS generated files
|
| 47 |
+
.DS_Store
|
| 48 |
+
.DS_Store?
|
| 49 |
+
._*
|
| 50 |
+
.Spotlight-V100
|
| 51 |
+
.Trashes
|
| 52 |
+
ehthumbs.db
|
| 53 |
+
Thumbs.db
|
| 54 |
+
|
| 55 |
+
# Testing
|
| 56 |
+
.coverage
|
| 57 |
+
.pytest_cache/
|
| 58 |
+
.tox/
|
| 59 |
+
.nox/
|
| 60 |
+
htmlcov/
|
| 61 |
+
.cache
|
| 62 |
+
nosetests.xml
|
| 63 |
+
coverage.xml
|
| 64 |
+
*.cover
|
| 65 |
+
*.py,cover
|
| 66 |
+
.hypothesis/
|
| 67 |
+
|
| 68 |
+
# Jupyter Notebook
|
| 69 |
+
.ipynb_checkpoints
|
| 70 |
+
|
| 71 |
+
# Environment variables
|
| 72 |
+
.env
|
| 73 |
+
.env.local
|
| 74 |
+
.env.*.local
|
| 75 |
+
|
| 76 |
+
# mypy
|
| 77 |
+
.mypy_cache/
|
| 78 |
+
.dmypy.json
|
| 79 |
+
dmypy.json
|
| 80 |
+
|
| 81 |
+
# Logs
|
| 82 |
+
*.log
|
| 83 |
+
|
| 84 |
+
# Database
|
| 85 |
+
*.db
|
| 86 |
+
*.sqlite3
|
| 87 |
+
|
| 88 |
+
# Temporary files
|
| 89 |
+
*.tmp
|
| 90 |
+
*.temp
|
| 91 |
+
|
| 92 |
+
# Local tooling
|
| 93 |
+
.extractrc
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.12
|
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Demo Application
|
| 2 |
+
|
| 3 |
+
A Python project for coding exercises and development.
|
| 4 |
+
|
| 5 |
+
## Setup for Development
|
| 6 |
+
|
| 7 |
+
This is the standard setup for working on this project. It will install the application and all the necessary development tools (pytest, black, etc.).
|
| 8 |
+
|
| 9 |
+
1. **Create the virtual environment:**
|
| 10 |
+
```bash
|
| 11 |
+
uv venv
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
2. **Install the project in editable mode with development dependencies:**
|
| 15 |
+
```bash
|
| 16 |
+
uv pip install -e ".[dev]"
|
| 17 |
+
```
|
| 18 |
+
This command installs the project, all development tools (like pytest and black), and creates the demo-app command-line script.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
## Running the Application
|
| 22 |
+
|
| 23 |
+
After setup, run the application using its console script entry point. This is the standard way to run the app and avoids any warnings.
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
uv run demo-app
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Development Tools
|
| 30 |
+
|
| 31 |
+
After setting up for development, you can use the following tools.
|
| 32 |
+
|
| 33 |
+
**Run Tests:**
|
| 34 |
+
```bash
|
| 35 |
+
uv run pytest
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
**Format Code:**
|
| 39 |
+
```bash
|
| 40 |
+
uv run black .
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
**Lint Code:**
|
| 44 |
+
```bash
|
| 45 |
+
uv run ruff check .
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
**Type Checking:**
|
| 49 |
+
```bash
|
| 50 |
+
uv run mypy src/
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Project Structure
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
src/demo_application/ # Main package
|
| 57 |
+
tests/ # Test files
|
| 58 |
+
pyproject.toml # Project configuration
|
| 59 |
+
```
|
pyproject.toml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["setuptools>=61.0", "wheel"]
|
| 3 |
+
build-backend = "setuptools.build_meta"
|
| 4 |
+
|
| 5 |
+
[project]
|
| 6 |
+
name = "demo_application"
|
| 7 |
+
version = "0.1.0"
|
| 8 |
+
description = "Demo application for technical interview"
|
| 9 |
+
readme = "README.md"
|
| 10 |
+
requires-python = ">=3.12"
|
| 11 |
+
dependencies = [
|
| 12 |
+
"setuptools>=80.9.0",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
+
[project.scripts]
|
| 16 |
+
demo-app = "demo_application.main:main"
|
| 17 |
+
|
| 18 |
+
[project.optional-dependencies]
|
| 19 |
+
dev = [
|
| 20 |
+
"black>=25.1.0",
|
| 21 |
+
"mypy>=1.16.1",
|
| 22 |
+
"pytest>=8.4.1",
|
| 23 |
+
"ruff>=0.12.2",
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
[tool.setuptools.packages.find]
|
| 27 |
+
where = ["src"]
|
| 28 |
+
|
| 29 |
+
[tool.setuptools.package-dir]
|
| 30 |
+
"" = "src"
|
src/demo_application/__init__.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .main import main
|
| 2 |
+
|
| 3 |
+
__all__ = ["main"]
|
src/demo_application/main.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def main():
|
| 2 |
+
print("Hello from demo application!")
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
if __name__ == "__main__":
|
| 6 |
+
main()
|
tests/__init__.py
ADDED
|
File without changes
|
tests/test_main.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from demo_application.main import main
|
| 2 |
+
import sys
|
| 3 |
+
from io import StringIO
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_main():
|
| 7 |
+
"""Test that main() prints the expected message."""
|
| 8 |
+
captured_output = StringIO()
|
| 9 |
+
sys.stdout = captured_output
|
| 10 |
+
main()
|
| 11 |
+
sys.stdout = sys.__stdout__
|
| 12 |
+
assert "Hello from demo application!" in captured_output.getvalue()
|