Material

Start of work

Self-task: Python project environment

You need to prepare the environment for your own public Python project from scratch. The assignment is independent of other homework.

Repository

Create an account at GitHub and create the first repository.

Setting up an SSH key

An SSH key allows you to securely work with GitHub from the command line without constantly entering your username and password. Follow official GitHub instructions.

Git

Install Git and clone the created repository. Make sure you know how to create branches, commit changes, receive updates, and push your branch to GitHub. Basic commands are described in Git Reference.

Development environment

Linters, formatters, and static analysis save time on routine checks. Each project's dependencies must be installed in a separate virtual environment.

Python version and virtual environment

pyenv helps install and select Python versions. The virtual environment itself can be created using a built-in module venv or a project manager, for example Poetry or uv. These are different tasks: pyenv selects the interpreter, and venv, Poetry or uv isolate project dependencies.

Project and Dependency Manager

Poetry manages project metadata, dependencies, lock file, building and publishing packages. New projects also often use uv. Select one tool and record it in the project's README.

pre-commit

pre-commit runs configured hooks before commit or manually. It is convenient to run a formatter, linter, and other quick checks on modified files.

Ruff and isort

Ruff — fast Python linter and formatter; it can also check and sort imports. In existing projects, it can be used separately to sort imports isort.

Black

Black — opinionated Python code formatter. It reduces formatting disputes and makes formatting reproducible.

Pylint

Pylint Performs static analysis of Python code and checks a wide range of potential errors and conventions. It is not an interpreter or a complete compliance check for all PEPs.

mypy

mypy — static type analyzer. Python remains a dynamically typed language, and type annotations and mypy help you find inconsistencies earlier and document code contracts.

Flake8

Flake8 combines PyFlakes, pycodestyle and McCabe checks. It is still supported and found in existing projects, although it is often replaced by Ruff in new configurations.

Practical part

  1. Create a minimal package or application with one function and one test.
  2. Choose one way to manage your environment and dependencies: venv + pip, Poetry or uv.
  3. Set up formatting and linting. No need to include Ruff, Black, isort, Pylint and Flake8 at the same time: choose a small consistent set and explain it in the README.
  4. Add type hints and the mypy setting if it is included in the selected set of checks.
  5. Connect pre-commit and check the entire repository with the command pre-commit run --all-files.
  6. Add .gitignore and .env.example; local environment and real secrets should not be committed.

Readiness criteria

  • the repository is cloned and configured using the README;
  • Python version and dependencies are fixed by the selected tool;
  • the test runs locally;
  • the formatter, linter, and selected type checking pass without errors;
  • pre-commit runs the stated checks;
  • not in the repository .venv, local .env, tokens and passwords.