-
Notifications
You must be signed in to change notification settings - Fork 55
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
add type hints #165
base: master
Are you sure you want to change the base?
add type hints #165
Conversation
If we implement types, then we need mypy on CI of course. |
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.
auto-formated by black
,
add missing type hints,
add ftp command SIZE
in tests.
I prefer pyftpdlib-style naming for FTP command process hander:
|
It's okay to have a |
There is no easy way to achieve this. like the following problems: |
t: T | None = f()
if t is None:
...
t.bar() |
@pohmelie thanks,just learned from https://mypy.readthedocs.io/en/stable/type_narrowing.html |
mypy and pytest finally all passed. |
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.
Need to fix all mypy errors. I expand linters with ruff (instead of flake8) and black formatter. And targeted python version 3.11.
use python keyworkd list as function name in pyathio.py/PathIO caused some problems: ruff:
Changed to list: async def _open(self, path: pathlib.Path, *args: list[Any], **kwargs: dict[Any, Any]) -> BufferedRandom: mypy:
|
Just add type alias for this, something like |
Good idea, but bad ideas of reusing the name of build-in function name |
It won't be changed. |
you are right!
https://docs.python.org/3/library/ftplib.html#ftplib.FTP.dir
Nikita Melentev ***@***.***> 于 2023年8月14日周一 下午11:49写道:
… ListType = list
Good idea, but bad ideas of reusing the name of build-in function name
list.
https://stackoverflow.com/questions/9109333/is-it-bad-practice-to-use-a-built-in-function-name-as-an-attribute-or-method-ide
It won't be changed. pathio.list() will remain pathio.list() it doesn't
shadow original list. So lets make a workaround here, since it just type
checks, not a real features/improvements or something. Think about it as what
API I want to use, I think it is obvious, that pathio.list() is what
client expect to see.
—
Reply to this email directly, view it on GitHub
<#165 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHW5AVF6JPIR3PI3S7ZIMLXVJCILANCNFSM6AAAAAAZ4GQOXA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
tested under Debian10/python3.7, Debian10/python3.11,