Skip to main content

Goose Types

Goose Types is a Python library for data types that support custom methods for type checking.

Goose types are classes with custom methods that define the behavior of isinstance() and issubclass() checks against themselves, along with some related annotations and error handling. In other words, a goose type is a frontend for Python’s metaclass hooks for custom instance and subclass checks.

Relation to duck typing

This is related to duck typing, and could even be interpreted as an implementation of it, but it is subtly different.

In contrast with a type in a nominal or structural type system, a duck type is defined by a partial structure or behavior that is checked at runtime. In this sense, a goose type is the same. However, duck typing is typically associated with one of two approaches that differ from goose typing.

One approach to duck typing is to apply EAFP: assume that the input implements the desired structure and behavior, and rely on error handling (supplementing as needed) to deal with non-compliant input. This is a fine approach for simple duck types and loose validation requirements, but for interfaces that require strict checking of complex type descriptions, the validation and error handling code can be cumbersome, littering a function and obscuring its essential functionality.

Another approach is to apply a form of nominal type checking at the level of attributes or methods, sometimes together with checking the multiplicity of arguments. By inspecting an object’s attributes, it is possible to check for a combination of interface conditions, such as attribute names, method names, and argument multiplicities, before commencing a destructive or expensive task.

Like the latter approach, goose types are more useful when it is desirable to perform complex validation up front. With Goose Types, complex type checking code to be extracted from a function body into the body of a goose type, leaving behind an invocation of isinstance() or issubclass(). In the sense that this is runtime checking of desirable interface behavior, this is like duck typing. However, unlike the conventional “walks”/”quacks” tests of duck typing, this can be used for checks that are exactly as extensive, specific, or generic as needed, without littering the code of functions that merely need to invoke a type check.

Changelog

Metadata

Release files for GooseTypes 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GooseTypes 0.1.1
File Size Uploaded Provenance
GooseTypes-0.1.1.tar.gz 22.2 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for GooseTypes 0.1.1
File Interpreter ABI Platform
GooseTypes-0.1.1-py2.7.egg Legacy Egg format - - Details
GooseTypes-0.1.1-py2-none-any.whl Python 2 none any Details

Total release size: 45.4 kB

Release files / GooseTypes-0.1.1.tar.gz

Download URL GooseTypes-0.1.1.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9943b6dc245a55334bf702a994f0660d2842ecb3d1d711e60ab20ad2aa0f9bba
BLAKE2b-256 checksum
How to use checksums
610991f72299ae60d84f03db969e6bd09575fa3b6ff20d39cdbc63a07d6e3ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / GooseTypes-0.1.1-py2.7.egg

Download URL GooseTypes-0.1.1-py2.7.egg
Size 9.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
10750ae642b7187eb0c54d240bb435ed11ba91694c5bdea671f2d88996c9ef82
BLAKE2b-256 checksum
How to use checksums
e76b91999126163c68f4ac9cb0fd6f704e63c2840e15c48714c60749a6d9437f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / GooseTypes-0.1.1-py2-none-any.whl

Download URL GooseTypes-0.1.1-py2-none-any.whl
Size 14.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
5733e0910ed9bd9e6292c0a4c4de12595c3479890a2a2d1453318320d0a74119
BLAKE2b-256 checksum
How to use checksums
4bb8fc57784797370345c045c42ee5eb0e7ed6b3f332904f3cc020e23538a3c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for GooseTypes 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

3 release files No provenance

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