Skip to content

javbachi/my-python-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Python Project

A Python project with proper structure and version control using Poetry.

Project Structure

my-python-project/
├── src/                    # Source code
│   └── my_python_project/  # Main package
├── tests/                  # Test files
├── docs/                   # Documentation
├── examples/               # Example usage
├── pyproject.toml          # Poetry configuration
└── README.md

Prerequisites

  • Python 3.8 or higher
  • Poetry (install with: pip install poetry)

Installation

  1. Clone the repository:
git clone <your-repo-url>
cd my-python-project
  1. Install dependencies with Poetry:
poetry install
  1. Activate the virtual environment:
poetry shell

Usage

Command Line Interface

The project includes a CLI with several commands:

# Greet someone
poetry run my-project hello --name Alice

# Calculate sum of numbers
poetry run my-project sum-numbers 1 2 3 4 5

# Process sample data
poetry run my-project process

# Show help
poetry run my-project --help

Python API

from my_python_project.core import DataProcessor, greet, calculate_sum

# Greet someone
message = greet("Alice")
print(message)  # "Hello, Alice! Welcome to My Python Project!"

# Calculate sum
total = calculate_sum([1, 2, 3, 4, 5])
print(total)  # 15

# Use the data processor
processor = DataProcessor()
processor.add_data("hello")
processor.add_data("world")
result = processor.process_data()
print(result)  # ['HELLO', 'WORLD']

Development

Setup Development Environment

  1. Install development dependencies:
poetry install --with dev
  1. Activate the virtual environment:
poetry shell

Code Quality

# Format code with Black
poetry run black src/ tests/

# Sort imports with isort
poetry run isort src/ tests/

# Check code style with flake8
poetry run flake8 src/ tests/

# Type checking with mypy
poetry run mypy src/

Testing

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=src

# Run tests in watch mode
poetry run pytest-watch

Building and Publishing

# Build the package
poetry build

# Publish to PyPI (requires authentication)
poetry publish

Poetry Commands Reference

# Add a dependency
poetry add package-name

# Add a development dependency
poetry add --group dev package-name

# Remove a dependency
poetry remove package-name

# Update dependencies
poetry update

# Show dependency tree
poetry show --tree

# Export requirements.txt (if needed)
poetry export -f requirements.txt --output requirements.txt

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Run code quality checks: poetry run black src/ tests/ && poetry run isort src/ tests/ && poetry run flake8 src/ tests/
  5. Run tests: poetry run pytest
  6. Commit your changes: git commit -m 'Add feature'
  7. Push to the branch: git push origin feature-name
  8. Submit a pull request

License

[Add your license here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages