Skip to content

Commit c567406

Browse files
authored
Write a bunch about why I don't want mini-plugins (#82)
1 parent 864d441 commit c567406

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

pep.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,44 @@ worse. Supporting filtering while mapping would make it even more bad
15271527

15281528
We can explore other options too if needed.
15291529

1530+
Perform type manipulations with normal Python functions
1531+
-------------------------------------------------------
1532+
1533+
One suggestion has been, instead of defining a new type language
1534+
fragment for type-level manipulations, to support calling (some subset
1535+
of) Python functions that serve as kind-of "mini-mypy-plugins".
1536+
1537+
The main advantage (in our view) here would be leveraging a more
1538+
familiar execution model.
1539+
1540+
One suggested advantage is that it would be a simplification of the
1541+
proposal, but we feel that the simplifications promised by the idea
1542+
are mostly a mirage, and that calling Python functions to manipulate
1543+
types would be quite a bit *more* complicated.
1544+
1545+
It would require a well-defined and safe-to-run subset of the language
1546+
(and standard library) to be defined that could be run from within
1547+
typecheckers. Subsets like this have been defined in other system
1548+
(see `Starlark <#starlark_>`_, the configuration language for Bazel),
1549+
but it's still a lot of surface area, and programmers would need to
1550+
keep in mind the boundaries of it.
1551+
1552+
Additionally there would need to be a clear specification of how types
1553+
are represented in the "mini-plugin" functions, as well defining
1554+
functions/methods for performing various manipulations. Those
1555+
functions would have a pretty big overlap with what this PEP currently
1556+
proposes.
1557+
1558+
If runtime use is desired, then either the type representation would
1559+
need to be made compatible with how ``typing`` currently works or we'd
1560+
need to have two different runtime type representations.
1561+
1562+
Whether it would improve the syntax is more up for debate; I think
1563+
that adopting some of the syntactic cleanup ideas discussed above (but
1564+
not yet integrated into the main proposal) would improve the syntactic
1565+
situation at lower cost.
1566+
1567+
15301568
Make the type-level operations more "strictly-typed"
15311569
----------------------------------------------------
15321570

@@ -1586,6 +1624,7 @@ Footnotes
15861624
.. _#prisma: https://www.prisma.io/
15871625
.. _#prisma-example: https://github.com/prisma/prisma-examples/tree/latest/orm/express
15881626
.. _#qb-test: https://github.com/vercel/python-typemap/blob/main/tests/test_qblike_2.py
1627+
.. _#starlark: https://starlark-lang.org/
15891628

15901629
.. [#broadcasting] http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
15911630
.. [#ref-impl] https://github.com/msullivan/mypy/tree/typemap

0 commit comments

Comments
 (0)