-
Notifications
You must be signed in to change notification settings - Fork 716
Include mypy in run_all_tests #2670
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
Conversation
4347631
to
07a8e9d
Compare
Codecov Report
@@ Coverage Diff @@
## main #2670 +/- ##
==========================================
+ Coverage 81.15% 81.17% +0.02%
==========================================
Files 51 51
Lines 5492 5493 +1
==========================================
+ Hits 4457 4459 +2
+ Misses 1035 1034 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments below.
Just curious - does modern mypy use mypyc compiler by default or is that a random side-effort?
@@ -32,7 +32,7 @@ | |||
from jax.experimental import pjit | |||
|
|||
|
|||
TAxisMetadata = TypeVar('TAxisMetadata', bound='AxisMetadata') | |||
TAxisMetadata = Any # TypeVar('TAxisMetadata', bound='AxisMetadata') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy doesn't support bound type-vars?! is this intentional Any cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy has had lots of trouble dealing with type-vars in general. I've tried to preserve their use, and just define them as Any. That way, we can reintroduce stricter checking later where possible.
@@ -30,10 +30,10 @@ | |||
|
|||
# Type annotations | |||
Array = jnp.ndarray | |||
Axes = Union[int, Iterable[int]] | |||
DType = jnp.dtype | |||
Axes = Union[int, Any] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add a IntSequence
(or something) to indicate what this Any
is supposed to be for a human reader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a great idea! Just as an FYI, there are many places in the code where pytype wanted something to be Iterabale
and mypy wanted something to be Sequence
. I couldn't make both happy so they ended up with Any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's both sad and funny... I wonder if there's a way to harmonize these two in our code better or to agitate for change - for now just another Any alias indicating we intend a sequence of ints should be ok
@@ -1559,7 +1559,7 @@ def loss(params, perturbations, inputs, targets): | |||
# [-1.456924 -0.44332537 0.02422847]] | |||
|
|||
""" | |||
value += self.variable(collection, name, lambda: jnp.zeros_like(value)).value | |||
value += self.variable(collection, name, lambda: jnp.zeros_like(value)).value # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we messing up internal type annotations in flax module methods to require this opt-out?
when we add new open source config files we need to configure them to be sync'd by the internal sync system first - I just added your mypy.ini file to #2693 - maybe rebase on that after it goes in (hopefully soon). |
That and mypy not being able to reason about flax's dataclasses were the
two annoying bits of making this PR work. On the bright side, as things
like mypy improve, we can reintroduce more stringent types.
…On Wed, 7 Dec 2022, 11:49 Anselm Levskaya, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In flax/linen/experimental/layers_with_named_axes.py
<#2670 (comment)>:
> @@ -30,10 +30,10 @@
# Type annotations
Array = jnp.ndarray
-Axes = Union[int, Iterable[int]]
-DType = jnp.dtype
+Axes = Union[int, Any]
that's both sad and funny... I wonder if there's a way to harmonize these
two in our code better or to agitate for change - for now just another Any
alias indicating we intend a sequence of ints should be ok
—
Reply to this email directly, view it on GitHub
<#2670 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACCULM2ZAD5ADW3S4JY33WMBTUBANCNFSM6AAAAAASOVUNZI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@zaxtax - seeing a small number of new internal pytype bugs of this sort:
|
@levskaya try now |
This continues work on #688 to include mypy in testing
Checklist
checks if that's the case).
discussion (please add a
link).
documentation guidelines.
(No quality testing = no merge!)