Skip to main content

IntelliType

IntelliType is a Python library that provides enhanced type annotations with custom structure and validation capabilities. It combines the power of static type hinting with runtime type checking and validation, while ensuring full intellisense support.

Publications

Features

  • Enhanced type annotations with full intellisense support
  • Runtime type checking and validation
  • Integration with Pydantic for robust data validation
  • Support for custom metadata in type definitions

Installation

You can install IntelliType using pip:

pip install crimson-intelli-type

Quick Start

Here's a simple example of how to use IntelliType:

from typing import List, Generic, TypeVar
from crimson.intelli_type import IntelliType

T = TypeVar('T')

class IntList(IntelliType[List[int]], Generic[T]):
    """Define your own type with hover capability."""

# You can use type_safe for validation if needed
valid_list: IntList[List[int]] = IntList.type_safe([1, 2, 3])

# This will raise an error due to incorrect data type
invalid_list: IntList[List[int]] = IntList.type_safe(["a", "b", "c"])

Adding Custom Metadata

IntelliType supports adding custom metadata. Use it in your own way.

class CustomTensor(IntelliType[Tuple[Tensor, Tensor], 'metadata'], Generic[T]):
    """A custom tensor type with metadata."""

print(CustomTensor.get_meta())  # Output: ('metadata',)

def forward(input_tensor: CustomTensor[Tuple[Tensor, Tensor], "(b, c, h, w), (b, 2c, h/2, w/2)"]):
    print(CustomTensor.get_meta())  # Output: ('(b, c, h, w), (b, 2c, h/2, w/2)',)
    ...

# You can also use metadata in more complex scenarios
class Model(nn.Module):
    pass

class AdvancedModel(IntelliType[nn.Module], Generic[T]):
    """General information."""

model: AdvancedModel[nn.Module, 'specific information', Model] = Model()

print(AdvancedModel.get_meta())  # Output: ('specific information', __main__.Model)

Why use Generic[T]?

Including Generic[T] in your IntelliType class definition is crucial for proper intellisense support. It allows your IDE to provide accurate type hints and autocompletion, enhancing your development experience and catching potential type errors early.

Examples

AutoPydantic

I used IntelliType to add type hints to AutoPydantic. The custom types are imported from another script. In the current script, you can easily access the type information by hovering over the variables.

^0.1.x version syntax

alt

alt

DeepLearning

Please check out the example in the link below. When using IntelliType, we don't write docstrings for attributes in the function documentation. Instead, arguments are individually documented, and their docstrings are reused throughout the code. This allows you to focus the function's documentation solely on describing its purpose and behavior.

DeepLearning Example

alt

Reusability

One of the biggest advantages of IntelliType is its reusability. Many arguments are often used across different functions. Traditionally, you would need to write the docstring for these arguments repeatedly.

The worst-case scenario is when you've written docstrings in multiple places and can't remember where they all are. When you modify one of your arguments, you'd need to edit all the related docstrings. However, with IntelliType, the information for your arguments is used consistently, allowing you to manage your package more cleanly and reliably.

Metadata

Release files for crimson-intelli-type 0.4.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 crimson-intelli-type 0.4.0
File Size Uploaded Provenance Actions
crimson_intelli_type-0.4.0.tar.gz 5.0 kB Without provenance Details for crimson_intelli_type-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crimson-intelli-type 0.4.0
File Interpreter ABI Platform Actions
crimson_intelli_type-0.4.0-py3-none-any.whl Python 3 none any Details for crimson_intelli_type-0.4.0-py3-none-any.whl

Total release size: 10.6 kB

Release files / crimson_intelli_type-0.4.0.tar.gz

Download URL crimson_intelli_type-0.4.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f096e56d386413b37aa6d13004f8ba48a286877b05b73d18f4ad8de2bf4af19e
BLAKE2b-256 checksum
How to use checksums
4a8c6f59afde4bf714a1aa8e80b5343848699d1bf4356062e76ad965bd638810
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release files / crimson_intelli_type-0.4.0-py3-none-any.whl

Download URL crimson_intelli_type-0.4.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e64a76a17c102f6597a7baded0c055d38accf7eb0215e492be96fa662efb5cf
BLAKE2b-256 checksum
How to use checksums
185ff4ba2a95af3ae8aa45638b308a2de79eb5dcf6ae3dc54177a0b6422c7028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Security for crimson-intelli-type 0.4.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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