Skip to content
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 annotations (closes #164) #176

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b4eff80
Adds a function for use in the decorator to retrieve arguments in a P…
9en9i Mar 14, 2024
66ab63e
Adds type annotations and some additional types
9en9i Mar 14, 2024
70887db
Adds mypy and pyright typechecker settings to pyproject
9en9i Mar 14, 2024
6954f1b
Merge branch 'aio-libs:master' into master
9en9i Mar 14, 2024
93193e5
Fix import TypeAlias
9en9i Mar 14, 2024
10f025f
adds typing_extensions dependencies
9en9i Mar 14, 2024
43d8b8f
adds new gitignore path
9en9i Mar 14, 2024
691c224
Fix typing
9en9i Mar 14, 2024
f96d2f9
Fix typing
9en9i Mar 14, 2024
b3c5676
Fix mypy settings
9en9i Mar 14, 2024
b12b817
Adds types for user fields
9en9i Mar 14, 2024
f697bf0
Returns mistakenly commented code
9en9i Mar 14, 2024
ba0c0aa
Adds missing type annotations for class fields
9en9i Mar 14, 2024
b28be58
Returns _to_list method
9en9i Mar 14, 2024
64f9a05
Fixes mypy error in detecting an unused "type: ignore" comment
9en9i Mar 14, 2024
a3fce7f
Fixes for pre-commit
9en9i Mar 14, 2024
d7fc1b6
Returns deleted comments
9en9i Mar 14, 2024
6785740
Returns an erroneously commented decorator
9en9i Mar 14, 2024
0b9e76c
Fix missing return type
9en9i Mar 14, 2024
c60be47
Fix wrong pythonVersion for pyright
9en9i Mar 14, 2024
5857dcc
Fixes incorrect mypy version limitation
9en9i Mar 14, 2024
4073d54
Removes the use of IS_PY37_PLUS for get_current_task
9en9i Mar 14, 2024
0e3ae8f
Fix pyright reportPossiblyUnboundVariable error
9en9i Mar 14, 2024
d61bf2d
Fix ruff warning: top-level linter settings are deprecated
9en9i Mar 17, 2024
ee593bc
Adds a package version restriction for typing-extensions
9en9i Mar 17, 2024
d80247e
Uses files parameter instead of packages for mypy now
9en9i Mar 17, 2024
7f95fd6
Corrects mistaken use of Generic where it should be Protocol
9en9i Mar 17, 2024
1bc0425
Makes naming consistent
9en9i Mar 17, 2024
0179a22
Fix path_io_factory type
9en9i Mar 17, 2024
33d12e0
Fix connection return type
9en9i Mar 17, 2024
51986e1
Corrects the name of variables
9en9i Mar 17, 2024
3d7399b
Moves self inside the class and makes it available under the client name
9en9i Mar 17, 2024
4081933
Changes the name of the variable
9en9i Mar 17, 2024
f355aeb
Adds _ParserType
9en9i Mar 17, 2024
820f40b
Removes PartialInfoDict
9en9i Mar 17, 2024
498f3e8
Removes version constraints for mypy && pyright
9en9i Mar 18, 2024
b16e5af
Removes object creation from the return expression
9en9i Mar 18, 2024
82086cf
Removes unnecessary annotations of class object variables
9en9i Mar 19, 2024
e49e219
Adds .DS_Store files to gitignore
9en9i Mar 19, 2024
fad3778
Corrects the ValueError error message
9en9i Mar 19, 2024
7da94b8
Adds type NotEmptyCodes
9en9i Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ __pycache__
.pytest_cache
.ruff_cache
coverage.xml
.coverage
.venv
venv
.DS_Store
36 changes: 35 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Topic :: Internet :: File Transfer Protocol (FTP)",
]
dependencies = [
"typing_extensions >= 4.10,<5.0",
]

[project.urls]
Github = "https://github.com/aio-libs/aioftp"
Expand All @@ -60,6 +63,10 @@ dev = [
"black",
"ruff",

# typecheckers
"pyright",
"mypy",

# docs
"sphinx",
"alabaster",
Expand All @@ -81,9 +88,11 @@ target-version = ["py38"]
[tool.ruff]
line-length = 120
target-version = "py38"
select = ["E", "W", "F", "Q", "UP", "I", "ASYNC"]
src = ["src"]

[tool.ruff.lint]
select = ["E", "W", "F", "Q", "UP", "I", "ASYNC"]

[tool.coverage]
run.source = ["./src/aioftp"]
run.omit = ["./src/aioftp/__main__.py"]
Expand All @@ -96,3 +105,28 @@ log_format = "%(asctime)s.%(msecs)03d %(name)-20s %(levelname)-8s %(filename)-15
log_date_format = "%H:%M:%S"
log_level = "DEBUG"
asyncio_mode = "strict"

[tool.pyright]
pythonVersion = "3.8"
strict = ["src"]
reportImplicitOverride = true
exclude = ["venv", ".venv", "build", "tests", "docs", "ftpbench.py"]

[tool.mypy]
files = "src/aioftp"
show_absolute_path = true
pretty = true
strict = true
enable_error_code = [
"explicit-override",
"redundant-self", "redundant-expr", "possibly-undefined",
]
warn_unreachable = true
disallow_any_generics = true
disallow_untyped_defs = true

[[tool.mypy.overrides]]
module = "tests"
strict = false
disallow_any_generics = false
disallow_untyped_defs = false
105 changes: 98 additions & 7 deletions src/aioftp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,106 @@

import importlib.metadata

from .client import *
from .common import *
from .errors import *
from .pathio import *
from .server import *
from .client import BaseClient, Client, Code, DataConnectionThrottleStreamIO
from .common import (
DEFAULT_ACCOUNT,
DEFAULT_BLOCK_SIZE,
DEFAULT_PASSWORD,
DEFAULT_PORT,
DEFAULT_USER,
END_OF_LINE,
AbstractAsyncLister,
AsyncListerMixin,
AsyncStreamIterator,
StreamIO,
StreamThrottle,
Throttle,
ThrottleStreamIO,
async_enterable,
setlocale,
with_timeout,
wrap_with_container,
)
from .errors import AIOFTPException, NoAvailablePort, PathIOError, PathIsNotAbsolute, StatusCodeError
from .pathio import (
AbstractPathIO,
AsyncPathIO,
MemoryPathIO,
PathIO,
PathIONursery,
)
from .server import (
AbstractUserManager,
AvailableConnections,
Connection,
ConnectionConditions,
MemoryUserManager,
PathConditions,
PathPermissions,
Permission,
Server,
User,
worker,
)
from .types import NotEmptyCodes, check_not_empty_codes

__version__ = importlib.metadata.version(__package__)
__version__ = importlib.metadata.version(__package__) # pyright: ignore[reportArgumentType]
version = tuple(map(int, __version__.split(".")))


__all__ = (
client.__all__ + server.__all__ + errors.__all__ + common.__all__ + pathio.__all__ + ("version", "__version__")
# client
"BaseClient",
"Client",
"DataConnectionThrottleStreamIO",
"Code",
# server
"Server",
"Permission",
"User",
"AbstractUserManager",
"MemoryUserManager",
"Connection",
"AvailableConnections",
"ConnectionConditions",
"PathConditions",
"PathPermissions",
"worker",
# errors
"AIOFTPException",
"StatusCodeError",
"PathIsNotAbsolute",
"PathIOError",
"NoAvailablePort",
# common
"with_timeout",
"StreamIO",
"Throttle",
"StreamThrottle",
"ThrottleStreamIO",
"END_OF_LINE",
"DEFAULT_BLOCK_SIZE",
"wrap_with_container",
"AsyncStreamIterator",
"AbstractAsyncLister",
"AsyncListerMixin",
"async_enterable",
"DEFAULT_PORT",
"DEFAULT_USER",
"DEFAULT_PASSWORD",
"DEFAULT_ACCOUNT",
"setlocale",
# pathio
"AbstractPathIO",
"PathIO",
"AsyncPathIO",
"MemoryPathIO",
"PathIONursery",
#
# types
"NotEmptyCodes",
"check_not_empty_codes",
#
"version",
"__version__",
)
4 changes: 3 additions & 1 deletion src/aioftp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import contextlib
import logging
import socket
from typing import Type

import aioftp

Expand Down Expand Up @@ -65,6 +66,7 @@
format="%(asctime)s [%(name)s] %(message)s",
datefmt="[%H:%M:%S]:",
)
path_io_factory: Type[aioftp.AbstractPathIO]
if args.memory:
user = aioftp.User(args.login, args.password, base_path="/")
path_io_factory = aioftp.MemoryPathIO
Expand All @@ -81,7 +83,7 @@
}[args.family]


async def main():
async def main() -> None:
server = aioftp.Server([user], path_io_factory=path_io_factory)
await server.run(args.host, args.port, family=family)

Expand Down
Loading