Skip to main content

Opinions

This is a Python library, designed to configure other Python projects with a set of tools to make development easier. Unlike tools like cookiecutter that are designed to start a project the right way, Opinions is designed to keep projects up to date with current tools and configurations as they change over time.

Originally, this tool came out of a frustration at how difficult it was to get Black, isort, pylint and pytest to work nicely together such that I could just run a single command and get told about all the ways I'd screwed up - I now prefer Ruff over the Black/isort/pylint trifecta - but there is still a bit of config that I hate copy-pasting between repos every time I start a new project. I wrote a hacky script that made this easier, which I then rewrote properly as Opinions.

Getting Started

  • Install opinions as a development dependancy - eg, for Poetry:
poetry add --dev opinions

or with pip:

pip install opinions
  • Apply the config
opinions apply
  • Check if the configured tools have found places where things could be improved:
pytest

Goals

  • Define a config for code formatting, linting and import sorting so everyone works to the same standard.
  • Make it easier to write correct code by promoting the use of type hinting.
  • Define a configuration for my editor to format code and sort imports automatically to minimize the amount of effort I need to spend meeting the code standard.
  • Highlight formatting, linting and type checking issues by integrating these tools into the testing workflow and editor.
  • Provide a "baseline" - the tool should not prevent projects from extending on top of the basic configuration.
  • Accept that best practice changes over time, and provide a mechanism to bring old projects up to date.

The Configuration

  • ruff, for linting, formatting and import sorting. Default config, except:
  • pytest, configured to run:
    • ruff linter and format checks (using pytest-ruff)
    • mypy checks (using pytest-mypy)
    • opinions check to check if the opinions config is correctly applied
  • VSCode configuration to:
    • Recommend the ruff integration extension be installed
    • Recommend the mypy integration extension be installed
    • Use ruff to format and organize imports on save
      • The ruff extension can also automatically fix some linter issues on save - this is explicitly not enabled as part of the configuration, but can be enabled if you want
  • If the project is using Poetry
    • Explicitly configure the PyPI repository if no other default source is configured
    • Configure poetry-dynamic-versioning to set the project version
  • Install poethepoet and configure it with a build task to build source and binary packages

Versioning and Compatibility

This project uses the following version scheme, based loosely off Semantic Versioning

  • The "patch" number will be incremented if the release only includes a minor or patch level upgrade to a dependency (eg, "upgrade mypy from x.y.z to x.y+1.0" or "upgrade pytest from x.y.z to x.y.z+1"), or internal changes that don't impact an interface point (ie, the command line arguments)
  • The "minor" number will be incremented (and the "patch" number reset to 0) if the release includes a major-level upgrade to a dependency (eg, "upgrade mypy from x.y.z to x+1.0.0"), if the release changes an interface point in a backwards-compatible way, or if the release adds a new feature
  • The "major" number will be incremented (and the "minor" and "patch" numbers reset to 0) if the release changes The Configuration such that users will need to run opinions apply, if the release includes a backwards-incompatible change to an interface point, or if the minimum supported version of Python changes

Opinions supports Python 3.10 or newer.

Metadata

Release files for opinions 2.0.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 opinions 2.0.0
File Size Uploaded
opinions-2.0.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opinions 2.0.0
File Interpreter ABI Platform
opinions-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / opinions-2.0.0.tar.gz

Download URL opinions-2.0.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f51cbde80d42fe152dbd306763aa3ef6d3ca86518053146135a4012009360653
BLAKE2b-256 checksum
How to use checksums
cea77eb0abffcd9a468981204059e067d1a6d4d91a7a3d31c8bdae7bdd5b2335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2024.

Transparency log

Release files / opinions-2.0.0-py3-none-any.whl

Download URL opinions-2.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f7bda5f44a62d9ee57b82e60ddd7127e315b039872e79519fcb3c66b48ae1ea
BLAKE2b-256 checksum
How to use checksums
3096f958b1fd338c9825e72c73607efc664e801bd477ecc1fe5046f00efdce88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

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