-
-
Notifications
You must be signed in to change notification settings - Fork 742
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
fix: mypy issues on importer.py and protocol/utils.py #991
Conversation
@@ -29,3 +29,39 @@ class LifespanSendMessage(TypedDict): | |||
"lifespan.shutdown.failed", | |||
] | |||
message: Optional[str] | |||
|
|||
|
|||
class HTTPScope(TypedDict): |
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.
cant we import the types from asgiref directly ?
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.
I would have to pip install from the latest asgiref branch, because that feature was not released yet. Do you prefer?
uvicorn/importer.py
Outdated
|
||
|
||
class ImportFromStringError(Exception): | ||
pass | ||
|
||
|
||
def import_from_string(import_str): | ||
def import_from_string(import_str: Any) -> 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.
def import_from_string(import_str: Any) -> Any: | |
def import_from_string(import_str: Union[str, ModuleType]) -> ModuleType: |
I've not tested it but it is what I would do, does this work ? Just asking if we can avoid Any
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.
Oh! That's so cool. I didn't know about ModuleType... I'm going to try it later. Thank you! :)
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.
It works. Applied.
ha no then I didn't know that, we would have then troubles pushing to pypi
with a pip git+
…On Wed, Mar 10, 2021 at 3:00 PM Marcelo Trylesinski < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In uvicorn/_types.py
<#991 (comment)>:
> @@ -29,3 +29,39 @@ class LifespanSendMessage(TypedDict):
"lifespan.shutdown.failed",
]
message: Optional[str]
+
+
+class HTTPScope(TypedDict):
I would have to pip install from the latest asgiref branch, because that
feature was not released yet. Do you prefer?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#991 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAINSPUWC3Z5JTN2RHVKX43TC5UOFANCNFSM4Y2HTIHQ>
.
--
benoit barthelet
http://pgp.mit.edu/pks/lookup?op=get&search=0xF150E01A72F6D2EE
|
@euri10 Done. Should I create an issue to track those mypy PRs? |
no we good I think |
I've already created (it helps to organize myself, but I can do it elsewhere), but if you think is just spam, I/you can close it. 😗 👍 |
|
||
|
||
class ImportFromStringError(Exception): | ||
pass | ||
|
||
|
||
def import_from_string(import_str): | ||
def import_from_string(import_str: Union[ModuleType, str]) -> ModuleType: |
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.
* fix some mypy issues * fix some mypy issues * add moduletype * fix flake8 issue
Following https://github.com/django/asgiref/blob/main/asgiref/typing.py .
Fix mypy issues on the following files: