Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations #203

Open
alexchandel opened this issue Aug 7, 2023 · 0 comments
Open

Add type annotations #203

alexchandel opened this issue Aug 7, 2023 · 0 comments

Comments

@alexchandel
Copy link

Type checkers like mypy and Pylance have become ubiquitous in modern Python for quickly writing safe, bug-free code. They catch bugs coming from obscure corner cases that programmers often overlook. Without annotations, they often attempt to infer the signatures of functions.

However, there are come cases where type checkers are unable to infer them, including in graphviz, for example here:

import graphviz

dot = graphviz.Digraph(comment='Foo', format='png')

with dot.subgraph(name=f'cluster_Foo') as c:  # Object of type "None" cannot be used with "with"
    # these all work fine:
    c.attr(label='foo')
    c.attr(style='filled', color='lightgrey')
    c.node_attr.update(style='filled', color='white')
    c.node('bar')

Could you add type annotations for common functions and methods like Dot.subgraph() to disambiguate their signatures?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant