-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
fixed type checking errors. #68
Conversation
I had to swap @DataClass for __init__(self, args, to, add, to, instance) syntax for mypy. It isn't ideal, but it was __less__ dumb than other possible workarounds, such as having self.app be a tuple of (app: ASGIApp,).
@ERM : I can see that travis-ci is firing, but I can't see the test results for this PR. I think you'll need to configure either the github webhooks settings or the travisc-ci run itself. |
@SKalt thanks for this! These are definitely some fixes I'd like to get in here - very much appreciate the PR. :) I'll give this a proper review soon, but looks good so far. |
@SKalt so I looked into the issue with dataclasses to see if there may be a solution that would allow us to keep using them with mypy. I'm thinking rather than refactoring the class syntax that we could try something like changing the # mangum/typing.py
from typing_extensions import Protocol
class ASGIApp(Protocol):
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
... What do you think? My initial testing with this seems to pass the linter and tests fine, though this definition might require some tweaking. |
The only trade-off I see is having to write
```
try:
from typing import Protocol # 3.8+
except ImportError:
from typing_extensions import Protocol #2.7-3.7
```
Which I'll say is better than reverting to full-on classes.
…On Wed, Nov 20, 2019, 01:01 Jordan Eremieff ***@***.***> wrote:
@SKalt <https://github.com/SKalt> so I looked into the issue with
dataclasses to see if there may be a solution that would allow us to keep
using them with mypy. I'm thinking rather than refactoring the class syntax
that we could try something like changing the ASGIApp definition to use
the callback protocol
<https://mypy.readthedocs.io/en/latest/protocols.html#callback-protocols>
as suggested in python/mypy#5485 (comment)
<python/mypy#5485 (comment)>:
# mangum/typing.py
class ASGIApp(Protocol):
def __call__(
self, scope: Scope, receive: Receive, send: Send
) -> typing.Awaitable[None]:
...
What do you think? My initial testing with this seems to pass the linter
and tests fine.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#68>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPUNZO7D6K2HE7BJHDTKNLQUTHFNANCNFSM4JOXGGFA>
.
|
@SKalt Great, let's go ahead with the |
did you happen to do your tests on top of my branch?
On Wed, Nov 20, 2019 at 8:35 PM Jordan Eremieff <[email protected]>
wrote:
… The only trade-off I see is having to write try: from typing import
Protocol # 3.8+ except ImportError: from typing_extensions import Protocol
#2.7-3.7 Which I'll say is better than reverting to full-on classes.
… <#m_8069571441260918262_>
On Wed, Nov 20, 2019, 01:01 Jordan Eremieff *@*.***> wrote: @SKalt
<https://github.com/SKalt> https://github.com/SKalt so I looked into the
issue with dataclasses to see if there may be a solution that would allow
us to keep using them with mypy. I'm thinking rather than refactoring the
class syntax that we could try something like changing the ASGIApp
definition to use the callback protocol
https://mypy.readthedocs.io/en/latest/protocols.html#callback-protocols
as suggested in python/mypy#5485
<python/mypy#5485> (comment) <python/mypy#5485
(comment)
<python/mypy#5485 (comment)>>: #
mangum/typing.py class ASGIApp(Protocol): def *call*( self, scope: Scope,
receive: Receive, send: Send ) -> typing.Awaitable[None]: ... What do you
think? My initial testing with this seems to pass the linter and tests
fine. — You are receiving this because you were mentioned. Reply to this
email directly, view it on GitHub <#68
<#68>,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACPUNZO7D6K2HE7BJHDTKNLQUTHFNANCNFSM4JOXGGFA
.
Great, let's go ahead with the Protocol solution here (and your proposed
import statements for 3.8 support) - thanks.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#68>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPUNZLRLAB7V5R4ULZ2JU3QUXQWBANCNFSM4JOXGGFA>
.
|
Yes. What I did to test was revert the |
Thanks! |
Resolves #67.
I had to swap
@dataclass
es for__init__(self, *args)
syntax to placate mypy. It isn't ideal, but it was less dumb than other possible workarounds, such as having self.app be a tuple of (app: ASGIApp,).demonstration of the trouble with
@dataclass