Skip to content

Instantly share code, notes, and snippets.

@dibrinsofor
dibrinsofor / cli ouput
Created November 19, 2024 06:13
mypy plugin to replace types
>> mypy --show-traceback tests/str_int.py
final def (a: builtins.str) -> builtins.int
final <class 'mypy.nodes.FuncDef'>
final def (a: builtins.str) -> builtins.int
final <class 'mypy.nodes.FuncDef'>
tests/str_int.py:2: error: Incompatible return value type (got "int", expected "str") [return-value]
@dibrinsofor
dibrinsofor / sample.py
Last active April 25, 2024 14:47
Flagging interested patterns from source code that uses Mypy
import pathlib
import click
import io, os
from enum import Enum
from typing import Optional, Union
import mypy.nodes
from mypy.parse import parse
from mypy.options import Options
from mypy.errors import CompileError, Errors
@dibrinsofor
dibrinsofor / table.ml
Created April 24, 2024 05:10
b2t2 table encoding
(* table *)
type 'a header = (string * 'a) list
type 'a header = string list
class ['a] table (header : 'b header) = object
val mutable header : 'b header = header
val mutable columns : 'a list = []
method columns : 'a list = columns
(* add rows, can't enforce the header *)