KotlinIsland / basedmypy

Based Python static type checker with baseline, sane default settings and based typing features
Other
140 stars 4 forks source link

`helpful-string` should apply to `print` and be configurable to apply to custom things (`basedtyping.HelpfulString`) #593

Open KotlinIsland opened 10 months ago

KotlinIsland commented 10 months ago

include/exclude config options:

[tool.mypy]
helpful_string_include = ["utils.amongus.AMONGUS"]
helpful_string_exclude = ["utils.amongus.SUS"]

config option for allowing None?

config option for allowing certain functions:print/anything

and basedtyping.HasHelpfulString/`basedtyping.UnhelpfulString, which can be used:

# HasHelpfulString is a kinda protocol for a type that has `__str__` etc
def thing(a: HasHelpfulString):
    f = f"asdf/{a}"
thing(None)  # error
thing(1)  # no error

# UnhelpfulString is a string that is allowed to contain stupid stuff
def print(s: UnhelpfulString): ...

print(f"{None}")   # okay, because the resulting string will be going to a `UnhelpfulString`
KotlinIsland commented 4 months ago

@DetachHead what about basedtyping.HelpfulString?

DetachHead commented 4 months ago

sure