Replies: 1 comment 1 reply
-
https://www.python.org/dev/peps/pep-0561/#partial-stub-packages I think is best option. But I think that also requires you use .pyi stubs. If you use .pyi stubs you can mark a package as partially typed and any files that have .pyi will use that, otherwise they will be treated as untyped. Alternative option I consider 80/20 rule of most tasks. What are most commonly used public API's? Type hint those and only those in line. Accept the rest lacking types and fill them in over time. Most libraries the commonly used functions is much smaller subset than the full api. disallow_untyped_calls is a pretty strict setting that I don't really expect to work with much of the python ecosystem today although this depends on what libraries you need. Some parts of ecosystem have better coverage then others. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to add type hints to RDFLib, but it's a big library and I don't think everything from it will be typed soon. My current approach has been to add
rdflib/py.typed
and to add type hints where I can.If we do this however, users who were using RDFLib with
import rdflib # type: ignore[import]
now have a problem which is that they have to add# type: ignore[no-untyped-call]
every time they use some untyped function/class from RDFLib if they run mypy withdisallow_untyped_calls=True
.What is the right approach here?
disallow_untyped_calls
?The downside here is maybe that they want to only enforce this for some libraries, but setting this per library as follows does not work:
The downside here is that users of RDFLib will get no benefit from type hints we add until we are done, which may be very long.
Are there other options I'm missing here?
The specific issue I'm trying to solve is RDFLib/rdflib#1447 and further context for us adding py.typed can be seen in RDFLib/rdflib#1407
Beta Was this translation helpful? Give feedback.
All reactions