Skip to content

janmarkuslanger/python_starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Starter

A starter template for Python projects, pre-configured with type checking, linting, formatting, unittests, and more. This project provides a solid foundation for clean, maintainable Python code.


🚀 Setup

  1. Create a virtual environment
    To create an isolated environment for your project, run:

    python3 -m venv venv
  2. Activate the virtual environment
    Activate it with the following command:

    On macOS/Linux:

    source venv/bin/activate

    On Windows:

    .\venv\Scripts\activate
  3. Install dependencies
    Install all the required dependencies listed in requirements.txt:

    pip3 install -r requirements.txt

    Alternatively, you can use make to handle installation:

    make install

🔧 Packages

This project includes the following packages for development:

  • mypy: A static type checker for Python, helping ensure that types are consistent and errors are caught early.
  • flake8: A linting tool to check your code for style violations and potential errors based on PEP 8 and other best practices.
  • black: An opinionated code formatter that enforces a consistent code style automatically.
  • pytest: A framework for writing simple and scalable test cases. Ideal for running unit tests and ensuring code reliability.

⚙️ Usage

You can use make for common tasks such as installation and testing:

Install dependencies

make install

Run linting with flake8

make lint

Format code with black

make format

Run tests with pytest

make test

📄 Configuration

  • mypy.ini: Configures mypy for static type checking.
  • .flake8: Configuration file for flake8 to enforce your preferred linting rules.
  • pyproject.toml: Configuration for black and other tools, ensuring consistent formatting across your project.
  • Makefile: Automates common tasks like installation, linting, formatting, and testing.

🛠️ Development Workflow

  1. Write your Python code in the src directory.
  2. Use make lint to check for style violations.
  3. Format your code with make format to ensure consistent formatting.
  4. Write unit tests in the tests directory.
  5. Run tests with make test to ensure everything works correctly.

📚 Additional Resources


This setup ensures that your Python project stays clean, well-tested, and easy to maintain. Happy coding! 🚀

About

My python starter repo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published