Skip to content

Repository files navigation

final_class

wemake.servicestestcodecovPython Versionwemake-python-styleguide

Final classes for python3.6+.

Features

  • No metaclass conflicts
  • No runtime overhead
  • No dependencies
  • Type hints included, PEP-561 and PEP-591 compatible
  • Designed to be as simple as possible

Why?

In languages like java we have a nice way to restrict subclassing any class by making it final:

publicfinalclassSomeClass {
// ...
}

In python we don't have such feature out of the box. That's where final_class library comes in!

This package works perfectly with @final from typing. So, with final_class you will have both type-checking and runtime checks.

Installation

pip install final_class

Usage

fromfinal_classimportfinal@finalclassExample(object): # You won't be able to subclass it!
...
classError(Example): # Raises `TypeError`
...

More?

Do you want more? Check out:

License

MIT.

Releases

Sponsor this project

Packages

Used by

Contributors

Languages