Skip to content

Powerful, flexible factory, registration, and validation tools for Python

License

Notifications You must be signed in to change notification settings

WithPrecedent/ashford

Repository files navigation

ashford

Version PyPI Latest Release GitHub Latest Release
Status Build Status Development Status Project Stability
Documentation Hosted By
Tools Documentation Linter Dependency Manager Pre-commit CI Editor Settings Repository Template Dependency Maintainer
Compatibility Compatible Python Versions Linux MacOS Windows
Stats PyPI Download Rate (per month) GitHub Stars GitHub Contributors GitHub Issues GitHub Forks

What is ashford?

This package provides classes and decorators for a variety of Python implementations of registration, factories, and type validators.

Why use ashford?

Registries

  • registered: a decorator that stores a registry in a registry attribute of the function or class which is wrapped by the decorator.
  • Registrar: a mixin for automatic subclass registration.

Factories

  • InstanceFactory: mixin that stores all subclass instances in the instances class attribute and returns stored instances when the create classmethod is called.
  • LibraryFactory: mixin that stores all subclasses and subclass instances in the library class attribute and returns stored subclasses and/or instances when the create classmethod is called.
  • SourceFactory: mixin that calls the appropriate creation method based on the type of passed first argument to create and the types stored in the keys of the sources class attribute.
  • StealthFactory: mixin that returns stored subclasses when the create classmethod is called without having a subclasses class attribute like SubclassFactory.
  • SubclassFactory: mixin that stores all subclasses in the subclasses class attribute and returns stored subclasses when the create classmethod is called.
  • TypeFactory: mixin that calls the appropriate creation method based on the type of passed first argument to create and the snakecase name of the type. This factory is prone to significant key errors unless you are sure of the snakecase names of all possible submitted type names. SourceFactory avoids this problem by allowing you to declare corresponding types and string names.

Validators

  • bonafide: decorator that validates or converts types based on type annotations of the wrapped function or dataclass (under construction)

ashford`s framework supports a wide range of coding styles. You can create complex multiple inheritance structures with mixins galore or simpler, compositional objects. Even though the data structures are necessarily object-oriented, all of the tools to modify them are also available as functions, for those who prefer a more funcitonal approaching to programming.

The project is also highly internally documented so that users and developers can easily make ashford work with their projects. It is designed for Python coders at all levels. Beginners should be able to follow the readable code and internal documentation to understand how it works. More advanced users should find complex and tricky problems addressed through efficient code.

Getting started

Requirements

[TODO: List any OS or other restrictions and pre-installation dependencies]

Installation

To install ashford, use pip:

pip install ashford

Usage

[TODO: Describe common use cases, with possible example(s)]

Contributing

Contributors are always welcome. Feel free to grab an issue to work on or make a suggested improvement. If you wish to contribute, please read the Contribution Guide and Code of Conduct.

Similar Projects

[TODO: If they exist, it is always nice to acknowledge other similar efforts]

Acknowledgments

[TODO: Mention any people or organizations that warrant a special acknowledgment]

License

Use of this repository is authorized under the Apache Software License 2.0.

About

Powerful, flexible factory, registration, and validation tools for Python

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages