Skip to content

Commit

Permalink
Version 0.05
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan committed Oct 2, 2023
1 parent 725f145 commit ebe4d73
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/anysqlite.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion anysqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"sqlite_version_info",
"threadsafety",
]
__version__ = "0.0.4"
__version__ = "0.0.5"
8 changes: 6 additions & 2 deletions anysqlite/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, _real_connection: sqlite3.Connection) -> None:

async def __aenter__(self) -> "Connection":
return self

async def __aexit__(self, *args: tp.Any, **kwargs: tp.Any) -> None:
return await self.close()

Expand Down Expand Up @@ -48,7 +48,10 @@ async def executemany(
self, sql: str, seq_of_parameters: tp.Iterable[tp.Iterable[tp.Any]]
) -> "Cursor":
real_cursor = await to_thread.run_sync(
self._real_connection.executemany, sql, seq_of_parameters, limiter=self._limiter
self._real_connection.executemany,
sql,
seq_of_parameters,
limiter=self._limiter,
)
return Cursor(real_cursor, self._limiter)

Expand All @@ -58,6 +61,7 @@ async def executescript(self, sql_script: str) -> "Cursor":
)
return Cursor(real_cursor, self._limiter)


class Cursor:
def __init__(self, real_cursor: sqlite3.Cursor, limiter: CapacityLimiter) -> None:
self._real_cursor = real_cursor
Expand Down
26 changes: 26 additions & 0 deletions typetest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import typing as tp
import sqlite3

P = tp.ParamSpec("P")
T = tp.TypeVar("T")
RT = tp.TypeVar("RT")

def copy_sig(_: tp.Callable[P, T], returns: tp.Callable[..., RT]) -> tp.Callable[[tp.Callable[..., tp.Any]], tp.Callable[P, RT]]:

def decorator(fnc: tp.Callable[..., tp.Any]) -> tp.Callable[P, RT]:

def inner(*args, **kwargs):
return fnc(*args, **kwargs)

return inner

return decorator

@copy_sig(sqlite3.connect, int.__new__)
async def connect(*args, **kwargs):
...


tp.reveal_type(connect)
a = connect()
tp.reveal_type(a)

0 comments on commit ebe4d73

Please sign in to comment.