Skip to content

Commit d1f4b79

Browse files
committed
Remove mypy
1 parent 7dcbf49 commit d1f4b79

15 files changed

Lines changed: 53 additions & 99 deletions

.github/workflows/typecheck.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jobs:
3131
- name: Install dependencies
3232
run: uv sync --all-extras
3333

34-
- name: Run mypy
34+
- name: Run ty
3535
run: |
3636
cd litecli
37-
uv run --no-sync --frozen -- python -m ensurepip
38-
uv run --no-sync --frozen -- python -m mypy --no-pretty --install-types --non-interactive .
37+
uv run ty check -v

pyproject.toml

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dependencies = [
1111
"cli-helpers[styles]>=2.2.1",
1212
"click>=4.1,!=8.1.*",
1313
"configobj>=5.0.5",
14-
"mypy>=1.17.1",
1514
"prompt-toolkit>=3.0.3,<4.0.0",
1615
"pygments>=1.6",
1716
"sqlparse>=0.4.4",
@@ -58,38 +57,6 @@ litecli = ["liteclirc", "AUTHORS"]
5857
[tool.ruff]
5958
line-length = 140
6059

61-
[tool.mypy]
62-
pretty = true
63-
strict_equality = true
64-
ignore_missing_imports = true
65-
warn_unreachable = true
66-
warn_redundant_casts = true
67-
warn_no_return = true
68-
warn_unused_configs = true
69-
show_column_numbers = true
70-
show_error_codes = true
71-
warn_unused_ignores = true
72-
python_version = "3.9"
73-
# Resolve module discovery reliably
74-
explicit_package_bases = true
75-
packages = ["litecli"]
76-
# Gradually tighten typing
77-
disallow_incomplete_defs = true
78-
disallow_untyped_defs = true
79-
no_implicit_optional = true
80-
warn_return_any = true
81-
exclude = [
82-
'^build/',
83-
'^dist/',
84-
'^\.tox/',
85-
'^\.venv/',
86-
'^venv/',
87-
'^\.mypy_cache/',
88-
'^\.pytest_cache/',
89-
'^\.ruff_cache/',
90-
]
91-
92-
9360
[tool.ty.environment]
9461
python-version = "3.9"
9562
root = [".", "litecli", "litecli/packages", "litecli/packages/special"]
@@ -103,6 +70,5 @@ exclude = [
10370
'**/.venv/',
10471
'**/.mypy_cache/',
10572
'**/.pytest_cache/',
106-
'**/.ruff_cache/',
107-
'**/tests/**'
73+
'**/.ruff_cache/'
10874
]

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# mypy: ignore-errors
2-
31
from __future__ import print_function
42

53
import os
64

75
import pytest
8-
from utils import create_db, db_connection, drop_tables
96

107
import litecli.sqlexecute
118

9+
from .utils import create_db, db_connection, drop_tables
10+
1211

1312
@pytest.fixture(scope="function")
1413
def connection():

tests/test_clistyle.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# -*- coding: utf-8 -*-
2-
# mypy: ignore-errors
2+
33
"""Test the litecli.clistyle module."""
44

55
import pytest
6-
76
from pygments.style import Style
87
from pygments.token import Token
98

@@ -17,7 +16,7 @@ def test_style_factory():
1716
cli_style = {"Token.Output.Header": header}
1817
style = style_factory("default", cli_style)
1918

20-
assert isinstance(style(), Style)
19+
assert isinstance(style, Style)
2120
assert Token.Output.Header in style.styles
2221
assert header == style.styles[Token.Output.Header]
2322

@@ -27,4 +26,4 @@ def test_style_factory_unknown_name():
2726
"""Test that an unrecognized name will not throw an error."""
2827
style = style_factory("foobar", {})
2928

30-
assert isinstance(style(), Style)
29+
assert isinstance(style, Style)

tests/test_completion_engine.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# mypy: ignore-errors
1+
import pytest
22

33
from litecli.packages.completion_engine import suggest_type
4-
import pytest
54

65

76
def sorted_dicts(dicts):

tests/test_completion_refresher.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# mypy: ignore-errors
2-
31
import time
4-
import pytest
52
from unittest.mock import Mock, patch
63

4+
import pytest
5+
76

87
@pytest.fixture
98
def refresher():

tests/test_dbspecial.py

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
# mypy: ignore-errors
2-
3-
from test_completion_engine import sorted_dicts
4-
from utils import assert_result_equal, dbtest, run
5-
61
from litecli.packages.completion_engine import suggest_type
72
from litecli.packages.special.utils import check_if_sqlitedotcommand, format_uptime
83

4+
from .test_completion_engine import sorted_dicts
5+
from .utils import assert_result_equal, dbtest, run
6+
97

108
def test_import_first_argument():
11-
test_cases = [
9+
test_cases: list[tuple[str, int]] = [
1210
# text, expecting_arg_idx
13-
[".import ", 1],
14-
[".import ./da", 1],
15-
[".import ./data.csv ", 2],
16-
[".import ./data.csv t", 2],
17-
[".import ./data.csv `t", 2],
18-
['.import ./data.csv "t', 2],
11+
(".import ", 1),
12+
(".import ./da", 1),
13+
(".import ./data.csv ", 2),
14+
(".import ./data.csv t", 2),
15+
(".import ./data.csv `t", 2),
16+
('.import ./data.csv "t', 2),
1917
]
2018
for text, expecting_arg_idx in test_cases:
2119
suggestions = suggest_type(text, text)
@@ -53,20 +51,14 @@ def test_list_or_show_create_tables():
5351

5452

5553
def test_format_uptime():
56-
seconds = 59
57-
assert "59 sec" == format_uptime(seconds)
58-
59-
seconds = 120
60-
assert "2 min 0 sec" == format_uptime(seconds)
61-
62-
seconds = 54890
63-
assert "15 hours 14 min 50 sec" == format_uptime(seconds)
64-
65-
seconds = 598244
66-
assert "6 days 22 hours 10 min 44 sec" == format_uptime(seconds)
67-
68-
seconds = 522600
69-
assert "6 days 1 hour 10 min 0 sec" == format_uptime(seconds)
54+
for seconds, human_readable_text in [
55+
("59", "59 sec"),
56+
("120", "2 min 0 sec"),
57+
("54890", "15 hours 14 min 50 sec"),
58+
("598244", "6 days 22 hours 10 min 44 sec"),
59+
("522600", "6 days 1 hour 10 min 0 sec"),
60+
]:
61+
assert human_readable_text == format_uptime(seconds)
7062

7163

7264
def test_indexes():

tests/test_llm_special.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# mypy: ignore-errors
1+
from unittest.mock import patch
22

33
import pytest
4-
from unittest.mock import patch
5-
from litecli.packages.special.llm import handle_llm, FinishIteration, USAGE
4+
5+
from litecli.packages.special.llm import USAGE, FinishIteration, handle_llm
66

77

88
@patch("litecli.packages.special.llm.llm")

tests/test_main.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# mypy: ignore-errors
2-
31
import os
42
import shutil
53
from collections import namedtuple
@@ -10,11 +8,13 @@
108
import click
119
import pytest
1210
from click.testing import CliRunner
13-
from utils import create_db, db_connection, dbtest, run
11+
from prompt_toolkit import PromptSession
1412

1513
from litecli.main import LiteCli, cli
1614
from litecli.packages.special.main import COMMANDS as SPECIAL_COMMANDS
1715

16+
from .utils import create_db, db_connection, dbtest, run
17+
1818
test_dir = os.path.abspath(os.path.dirname(__file__))
1919
project_dir = os.path.dirname(test_dir)
2020
default_config_file = os.path.join(project_dir, "tests", "liteclirc")
@@ -137,6 +137,7 @@ def test_help_strings_end_with_periods():
137137
for param in cli.params:
138138
if isinstance(param, click.core.Option):
139139
assert hasattr(param, "help")
140+
assert isinstance(param.help, str)
140141
assert param.help.endswith(".")
141142

142143

@@ -160,7 +161,7 @@ class TestExecute:
160161
def server_type(self):
161162
return ["test"]
162163

163-
class PromptBuffer:
164+
class PromptBuffer(PromptSession):
164165
output = TestOutput()
165166

166167
m.prompt_app = PromptBuffer()
@@ -268,6 +269,7 @@ def test_import_command(executor):
268269

269270
def test_startup_commands(executor):
270271
m = LiteCli(liteclirc=default_config_file)
272+
assert m.startup_commands
271273
assert m.startup_commands["commands"] == [
272274
"create table startupcommands(a text)",
273275
"insert into startupcommands values('abc')",
@@ -328,7 +330,8 @@ def test_get_prompt(mock_datetime):
328330
assert lc.get_prompt(r"\s") == "42"
329331

330332
# 11. Test when dbname is None => (none)
331-
lc.connect(None) # Simulate no DB connection
333+
lc.connect(None) # ty: ignore[invalid-argument-type]
334+
# Simulate no DB connection and incorrect argument type
332335
assert lc.get_prompt(r"\d") == "(none)"
333336
assert lc.get_prompt(r"\f") == "(none)"
334337

tests/test_parseutils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# mypy: ignore-errors
2-
31
import pytest
2+
43
from litecli.packages.parseutils import (
54
extract_tables,
6-
query_starts_with,
7-
queries_start_with,
85
is_destructive,
6+
queries_start_with,
7+
query_starts_with,
98
)
109

1110

0 commit comments

Comments
 (0)