ApeWorX / eth-pydantic-types

ETH Pydantic types
http://docs.apeworx.io/eth-pydantic-types/
Apache License 2.0
3 stars 5 forks source link

Make mypy integration that treat all HexBytes as interop #9

Open antazoey opened 5 months ago

antazoey commented 5 months ago

Overview

Right now, if you use hexbytes.HexBytes in a spot expecting eth_pydantic_types.HexBytes, mypy gets mad. I'd like to integrate with mypy to ignore these concerns automatically.

Specification

from chat gpt:

from typing import Callable
from mypy.plugin import Plugin
from mypy.nodes import TypeInfo, ClassDef

class HexBytesPlugin(Plugin):
    def get_class_decorator_hook(self, fullname: str) -> Callable[[TypeInfo], None]:
        if fullname == "HexBytes":  # Adjust the condition based on your identification logic
            return self.handle_hexbytes_class
        return lambda cls: None

    def handle_hexbytes_class(self, cls: ClassDef) -> None:
        # Adjust the class definition or type information for HexBytes as needed
        pass

def plugin(version: str):
    return HexBytesPlugin

Dependencies

Include links to any open issues that must be resolved before this feature can be implemented.

linear[bot] commented 5 months ago

APE-1745 Make mypy integration that treat all HexBytes as interop