Skip to main content

Bookstore Package

Tests Lint codecov PyPI version Google Slides

A demonstration package for teaching Python best practices. This package implements a simple book management system to illustrate:

  • Clean code principles
  • Proper package structure
  • Good naming conventions
  • Comprehensive documentation
  • Type hints
  • Testing practices

Project Structure

bookstore/
├── src/
│   └── bookstore/
│       ├── __init__.py
│       ├── models/
│       │   ├── __init__.py
│       │   └── book.py
│       ├── repositories/
│       │   ├── __init__.py
│       │   └── book_repository.py
│       └── exceptions/
│           ├── __init__.py
│           └── book_exceptions.py
└── tests/
    └── test_book.py

Installation

For development:

pip install -e ".[dev]"

Usage Example

from bookstore.models.book import Book
from bookstore.repositories.book_repository import BookRepository

# Create a new book
book = Book(
    isbn="978-0-7475-3269-9",
    title="Harry Potter and the Philosopher's Stone",
    author="J.K. Rowling",
    publication_year=1997
)

# Store the book
repository = BookRepository()
repository.add_book(book)

# Retrieve a book
found_book = repository.get_book_by_isbn("978-0-7475-3269-9")

Development Practices Demonstrated

  1. Clear Module Structure: Separation of concerns between models, repositories, and exceptions
  2. Type Hints: All functions include proper type annotations
  3. Documentation: Google-style docstrings with examples
  4. Error Handling: Custom exceptions and proper error messages
  5. Testing: Comprehensive unit tests with pytest
  6. Clean Code: Short, focused methods with clear responsibilities

Contributing

This is an educational project. Feel free to fork and experiment, but we have some tasks for you to complete.

Tasks 1

Add Book Categories/Genres

Branch name: feature/book-categories

Scope:

  • Add category field to Book class
  • Add category validation
  • Update repository to search by category

PR Learning Points:

  • Single responsibility principle
  • Database schema changes
  • Test coverage for new field

Tasks 2

Add Book Search Functionality

Branch name: feature/search-books

Scope:

  • Add search by title/author
  • Implement fuzzy matching
  • Add search result pagination

PR Learning Points:

  • Algorithm implementation
  • Performance considerations
  • Documentation of search parameters

Tasks 3

Add Book rating

Branch name: feature/book-ratings

Scope:

  • Add Rating class
  • Implement rating statistics
  • Add rating constraints (1-5 stars)

PR Learning Points:

  • Relationship between models
  • Data validation
  • Statistical calculations

Tasks 4

Add Book Import/Export

Branch name: feature/import-export

Scope:

  • CSV import/export
  • JSON serialization
  • Data validation

PR Learning Points:

  • File handling
  • Data formats
  • Error handling

Branch handling

It is important to know how to hadle and operate with branches.

Contributing

Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.

PR Template

Please refer to the PR Template on the expected format for PRs.

Continuous Integration

This project uses GitHub Actions for continuous integration and deployment:

  • Testing: Automated tests run on multiple Python versions (3.8-3.11)
  • Code Coverage: Coverage reports are uploaded to Codecov
  • Linting: Code quality checks using Black, isort, mypy, and pylint
  • Publishing: Automatic package publishing to PyPI on new releases

Status Checks

Before merging a PR, ensure all status checks pass:

  1. All tests pass across Python versions
  2. Code coverage meets minimum threshold (90%)
  3. Code follows style guidelines (Black, isort)
  4. No type checking errors (mypy)
  5. No linting issues (pylint)

Metadata

Release files for nelson-semtec-bookstore 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nelson-semtec-bookstore 0.1.0
File Size Uploaded Provenance Actions
nelson_semtec_bookstore-0.1.0.tar.gz 10.4 kB Without provenance Details for nelson_semtec_bookstore-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nelson-semtec-bookstore 0.1.0
File Interpreter ABI Platform Actions
nelson_semtec_bookstore-0.1.0-py3-none-any.whl Python 3 none any Details for nelson_semtec_bookstore-0.1.0-py3-none-any.whl

Total release size: 19.9 kB

Release files / nelson_semtec_bookstore-0.1.0.tar.gz

Download URL nelson_semtec_bookstore-0.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fb1281ad1aa6875a63dbba9270f6a67386f454d56ad5fa71587b0dcfde91a36f
BLAKE2b-256 checksum
How to use checksums
8ee446a349266e90cf7b5f3558236adbcbcc5cff514249f38b1b78bca0b56fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release files / nelson_semtec_bookstore-0.1.0-py3-none-any.whl

Download URL nelson_semtec_bookstore-0.1.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb8df74235ea772c67b8fa64086396ee142614ad0b8c5a6c15879140da67fe47
BLAKE2b-256 checksum
How to use checksums
da5ae90c06bfcabe6f6a9c07a2f94657a33a9d7cbdb4190188902077ef093df8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Security for nelson-semtec-bookstore 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page