Skip to content

Commit

Permalink
CI: Fix some mypy issues in backends (#2857)
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored Jul 14, 2021
1 parent f7cf96b commit 40bd815
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
6 changes: 3 additions & 3 deletions ibis/backends/postgres/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def _string_agg(t, expr):


# translate strftime spec into mostly equivalent PostgreSQL spec
_scanner = re.Scanner(
_scanner = re.Scanner( # type: ignore # re does have a Scanner attribute
# double quotes need to be escaped
[('"', lambda scanner, token: r'\"')]
+ [
Expand Down Expand Up @@ -439,7 +439,7 @@ def _compile_regex_extract(element, compiler, **kw):
return result


def _regex_extract(t, expr):
def _regex_extract_(t, expr):
string, pattern, index = map(t.translate, expr.op().args)
result = sa.case(
[
Expand Down Expand Up @@ -652,7 +652,7 @@ def _day_of_week_name(t, expr):
ops.RegexSearch: infix_op('~'),
ops.RegexReplace: _regex_replace,
ops.Translate: fixed_arity('translate', 3),
ops.RegexExtract: _regex_extract,
ops.RegexExtract: _regex_extract_,
ops.StringSplit: fixed_arity(sa.func.string_to_array, 2),
ops.StringJoin: _string_join,
ops.FindInSet: _find_in_set,
Expand Down
5 changes: 3 additions & 2 deletions ibis/backends/postgres/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import os
from pathlib import Path
from typing import Optional
from typing import Generator, Optional

import pytest

Expand Down Expand Up @@ -76,6 +76,7 @@ def connect(data_directory: Path):
def geo(self) -> Optional[ir.TableExpr]:
if 'geo' in self.db.list_tables():
return self.db.geo
return None


def _random_identifier(suffix):
Expand Down Expand Up @@ -139,7 +140,7 @@ def translate():


@pytest.fixture
def temp_table(con) -> str:
def temp_table(con) -> Generator[str, None, None]:
"""
Return a temporary table name.
Expand Down
3 changes: 2 additions & 1 deletion ibis/backends/postgres/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import inspect
import itertools
from textwrap import dedent
from typing import Any, Dict

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import dialect
Expand All @@ -17,7 +18,7 @@
)
from ibis.expr.signature import Argument as Arg

_udf_name_cache = collections.defaultdict(itertools.count)
_udf_name_cache: Dict[str, Any] = collections.defaultdict(itertools.count)


class PostgresUDFError(IbisError):
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sqlite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def connect(data_directory: Path):
'IBIS_TEST_SQLITE_DATABASE', data_directory / 'ibis_testing.db'
)
)
return ibis.sqlite.connect(str(path))
return ibis.sqlite.connect(str(path)) # type: ignore

@property
def functional_alltypes(self) -> ir.TableExpr:
Expand Down
17 changes: 6 additions & 11 deletions ibis/backends/sqlite/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@
import pandas.testing as tm
import pytest
import sqlalchemy as sa
from packaging.version import parse

import ibis # noqa: E402
import ibis.config as config # noqa: E402
import ibis.expr.datatypes as dt # noqa: E402
from ibis import literal as L # noqa: E402

try:
from packaging.version import parse as get_version
except ImportError:
from distutils.version import LooseVersion as get_version

import ibis
import ibis.expr.datatypes as dt
from ibis import config
from ibis import literal as L

pytestmark = pytest.mark.sqlite

Expand Down Expand Up @@ -426,7 +421,7 @@ def test_category_label(alltypes, df):


@pytest.mark.xfail(
get_version(sqlite3.sqlite_version) < get_version('3.8.3'),
parse(sqlite3.sqlite_version) < parse('3.8.3'),
raises=sa.exc.OperationalError,
reason='SQLite versions < 3.8.3 do not support the WITH statement',
)
Expand Down

0 comments on commit 40bd815

Please sign in to comment.