Skip to content

Commit

Permalink
Merge pull request #110 from nackjicholson/v4.0
Browse files Browse the repository at this point in the history
v4.0
  • Loading branch information
zx80 authored Jul 10, 2022
2 parents 4393aad + 917b6a5 commit 67e98c3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions aiosql/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ def ctx_mgr(self, conn, *args, **kwargs):


def _create_methods(query_datum: QueryDatum, is_aio: bool) -> List[Tuple[str, QueryFn]]:
"""Internal function to feed add_queries."""
fn = _make_sync_fn(query_datum)
if is_aio:
fn = _make_async_fn(fn)

ctx_mgr = _make_ctx_mgr(fn)

# TODO: 4.0.0 release
# TODO in a later release?
# The return can and should be simplified to List[QueryFn]
# i.e.
# return [fn, ctx_mgr] and [fn]
# i.e. "return [fn, ctx_mgr] and [fn]"
if query_datum.operation_type == SQLOperationType.SELECT:
return [(fn.__name__, fn), (ctx_mgr.__name__, ctx_mgr)]
else:
Expand Down Expand Up @@ -158,9 +158,9 @@ def add_query(self, query_name: str, fn: Callable):
def add_queries(self, queries: List[Tuple[str, QueryFn]]):
"""Add query methods to `Queries` instance."""
for query_name, fn in queries:
# TODO: Could be query_name = fn.__name__.rpartition(".")[2]
# TODO Could be query_name = fn.__name__.rpartition(".")[2]
# if the interface here were changed to just queries being
# a List[QueryFn]
# a List[QueryFn] (see _create_methods)
query_name = query_name.rpartition(".")[2]
self.add_query(query_name, MethodType(fn, self))

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
github_doc_root = "https://github.com/nackjicholson/aiosql/tree/master/docs/source/"

# The full version, including alpha/beta/rc tags
release = "3.4.1"
release = "4.0"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = aiosql
version = 3.4.1
version = 4.0
author = William Vaughn
author_email = vaughnwilld@gmail.com
description = Simple SQL in Python
Expand Down
5 changes: 5 additions & 0 deletions tests/test_loading.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import inspect
from pathlib import Path
from unittest import mock
import re

import aiosql
from aiosql.exceptions import SQLParseException
Expand All @@ -26,6 +27,10 @@ def sql(sql_file):
return f.read()


def test_version():
assert re.match(r"\d+\.\d+$", aiosql.__version__)


def test_frompath_queries_cls(sql_dir):
class TestQueries(Queries):
pass
Expand Down

0 comments on commit 67e98c3

Please sign in to comment.