-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
On mypy libraries #724
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
Comments
Related: should For now I'll go with the exception, but it is something to think about. |
I've decided to do 9: don't do anything for now, but we may return to this later after mypy is (closer to) production quality. Mypy is a small enough project that splitting it further probably won't improve things much (if at all), but moving things around will likely confuse people and slow down progress. To make my point clear: I want to focus on things like improving Python, library and PEP 484 compatibility, fixing bugs, improving usability, improving documentation, improving performance and adding tests -- not on restructuring the mypy implementation. I'm much happier with the quality of the mypy code base than most projects I've worked on and it has the benefit that a bunch of people can already find their way around it. Smaller refactorings such as splitting individual modules or cleaning up some functions is 100% okay but should be discussed first to confirm that it will be a net benefit. Each refactoring also has a cost associated (somebody has to do it, somebody has to review it, it may break stuff, people have to learn how the new thing works, open branches won't merge cleanly, etc.). |
I notice that a lot of current and future code in the mypy repository is not strictly related to mypy's core goal of being a static type-checker. You can detect these by the fact that they have few, if any, imports from the rest of mypy.
It would be cleaner if these were segregated to a separate package, especially for unit-testing purposes.
Current examples of nodes that are, or are leaning, this way:
codec
: Already a subpackage, which is documented to be used in a certain way, but it should be simple to keep it minimally compatible even if we figure out how to autoregister encodings.errors
: I am planning a full rewrite (in a newmypy.syntax
package) to add column and caret support, and possibly also other output formats for machine consumption. Some of this logic is obviously mypy-specific; other parts would be useful to others.messages
: It's not clear to me why this exists at all right now, but if it continues to exist, it ought to be a simple wrapper aroundgettext
. Clearer vision is required to see whether or not it will have any value on its own. See also Remove obsolete messages from mypy.messages #242myunit
: I am currently doing related cleanup as part of Fix/Improve Test Driver #721 (I need a separate module to run it as__main__
since it is also imported-from), but it would be nice if mypy tests could be run entirely by a standard test framework (I find pytest more convenient in that you don't have to arbitrarily add classes and can do proper fixtures instead of plain setup/teardown). This would make it easier to, say, collect coverage, run subsets of tests, and run tests in parallel (the current parallelization in Fix/Improve Test Driver #721 is a hack and very coarse)stubgen
: Ought to be a subpackage at least, and separate out the__main__
logic from the look-at-python logic.util
: Although not mypy-specific, does not stand on its own. Leave it here, every project has a garbage module.And stuff I have created or am working on:
waiter
: a module I just added as a hack to make testing less intolerable. Only truly effective on Linux with Python 3.3 or later. Might be acting funny (but correct) on Travis, but I'm not sure. The details might change significantly if we stop running on the legacy infrastructure.myargs
: an idea I have to make implement argument parsing in a typesafe and readable manner, by introspecting the function/constructor annotations (withtyping.get_type_hints
- should it defer to__init__
automatically if passed a class and__call__
if passed any other Callable?).Possible approaches for what to do with general-purpose modules:
mypylibs
package, e.g.mypylibs.myunit
. (Name subject to bikeshedding; still will be the same pip package though).mypy.libs
subpackage, e.g.mypy.libs.myunit
. (Name subject to bikeshedding).mypy
, even if they would only have an__init__.py
.myunit
.mypy
.mypylibs
.mypy.libs
.My preference is
2
, but keep open the possibility of7
. Any such top-level packages should keep themy*
pattern.The text was updated successfully, but these errors were encountered: