Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: lint

on:
pull_request:
paths-ignore:
- '**.md'
- 'AUTHORS'

jobs:
linters:
name: Typecheck
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.13'

- uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1
with:
version: 'latest'

- name: Install dependencies
run: uv sync --all-extras

- name: Run mypy
run: |
uv run --no-sync --frozen -- python -m mypy --no-pretty --install-types .
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Upcoming Release (TBD)
======================

Internal
--------

* Add limited typechecking to CI.


1.35.0 (2025/07/18)
======================

Expand Down
2 changes: 2 additions & 0 deletions mycli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import importlib.metadata

__version__ = importlib.metadata.version("mycli")
2 changes: 2 additions & 0 deletions mycli/clibuffer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from prompt_toolkit.application import get_app
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.filters import Condition
Expand Down
2 changes: 2 additions & 0 deletions mycli/clistyle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import logging

from prompt_toolkit.styles import Style, merge_styles
Expand Down
2 changes: 2 additions & 0 deletions mycli/clitoolbar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from prompt_toolkit.application import get_app
from prompt_toolkit.enums import EditingMode
from prompt_toolkit.key_binding.vi_state import InputMode
Expand Down
2 changes: 2 additions & 0 deletions mycli/compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Platform and Python version compatibility support."""

import sys
Expand Down
2 changes: 2 additions & 0 deletions mycli/completion_refresher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from collections import OrderedDict
import threading

Expand Down
2 changes: 2 additions & 0 deletions mycli/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from copy import copy
from importlib import resources
from io import BytesIO, TextIOWrapper
Expand Down
2 changes: 2 additions & 0 deletions mycli/key_bindings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import logging

from prompt_toolkit.enums import EditingMode
Expand Down
2 changes: 2 additions & 0 deletions mycli/lexer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from pygments.lexer import inherit
from pygments.lexers.sql import MySqlLexer
from pygments.token import Keyword
Expand Down
2 changes: 2 additions & 0 deletions mycli/magic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import logging

import sql.connection
Expand Down
2 changes: 2 additions & 0 deletions mycli/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from collections import defaultdict, namedtuple
import logging
import os
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/completion_engine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import sqlparse
from sqlparse.sql import Comparison, Identifier, Where

Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/filepaths.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os
import platform

Expand Down
4 changes: 2 additions & 2 deletions mycli/packages/hybrid_redirection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import sqlglot

from mycli.compat import WIN
from mycli.packages.special.delimitercommand import DelimiterCommand
from mycli.compat import WIN # type: ignore[attr-defined]
from mycli.packages.special.delimitercommand import DelimiterCommand # type: ignore[attr-defined]

logger = logging.getLogger(__name__)
delimiter_command = DelimiterCommand()
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/paramiko_stub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""A module to import instead of paramiko when it is not available (to avoid
checking for paramiko all over the place).

Expand Down
8 changes: 5 additions & 3 deletions mycli/packages/parseutils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# type: ignore

import re

import sqlglot
import sqlparse
from sqlparse.sql import Function, Identifier, IdentifierList
from sqlparse.tokens import DML, Keyword, Punctuation
import sqlparse # type: ignore[import-untyped]
from sqlparse.sql import Function, Identifier, IdentifierList # type: ignore[import-untyped]
from sqlparse.tokens import DML, Keyword, Punctuation # type: ignore[import-untyped]

cleanup_regex = {
# This matches only alphanumerics and underscores.
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/prompt_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import sys

import click
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/special/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

__all__ = []


Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/special/dbcommands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import logging
import os
import platform
Expand Down
4 changes: 3 additions & 1 deletion mycli/packages/special/delimitercommand.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# type: ignore

import re

import sqlparse
import sqlparse # type: ignore[import-untyped]


class DelimiterCommand(object):
Expand Down
3 changes: 3 additions & 0 deletions mycli/packages/special/favoritequeries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# type: ignore


class FavoriteQueries(object):
section_name = "favorite_queries"

Expand Down
9 changes: 6 additions & 3 deletions mycli/packages/special/iocommands.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# type: ignore

import locale
import logging
import os
import re
import shlex
import subprocess
from time import sleep
from typing import Any

import click
import pyperclip
import sqlparse
import pyperclip # type: ignore[import-untyped]
import sqlparse # type: ignore[import-untyped]

from mycli.compat import WIN
from mycli.packages.prompt_utils import confirm_destructive_query
Expand All @@ -25,7 +28,7 @@
tee_file = None
once_file = None
written_to_once_file = False
PIPE_ONCE = {
PIPE_ONCE: dict[str, Any] = {
'process': None,
'stdin': [],
'stdout_file': None,
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/special/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from collections import namedtuple
import logging

Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/special/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os
import subprocess

Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/tabular_output/sql_format.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Format adapter for sql."""

from mycli.packages.parseutils import extract_tables_from_complete_statements
Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/toolkit/fzf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import re
from shutil import which

Expand Down
2 changes: 2 additions & 0 deletions mycli/packages/toolkit/history.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os
from typing import List, Tuple, Union

Expand Down
3 changes: 3 additions & 0 deletions mycli/shortcuts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# type: ignore


def server_date(sqlexecute, quoted: bool = False) -> str:
server_date_str = sqlexecute.now().strftime('%Y-%m-%d')
if quoted:
Expand Down
2 changes: 2 additions & 0 deletions mycli/sqlcompleter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from collections import Counter
import logging
import re
Expand Down
2 changes: 2 additions & 0 deletions mycli/sqlexecute.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import enum
import logging
import re
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ssh = ["paramiko", "sshtunnel"]
dev = [
"behave>=1.2.6",
"coverage>=7.2.7",
"mypy>=1.16.1",
"pexpect>=4.9.0",
"pytest>=7.4.4",
"pytest-cov>=4.1.0",
Expand Down Expand Up @@ -99,3 +100,17 @@ exclude = [
'build',
'mycli_dev',
]

[tool.mypy]
pretty = true
strict_equality = true
ignore_missing_imports = true
warn_unreachable = true
warn_redundant_casts = true
warn_no_return = true
warn_unused_configs = true
show_column_numbers = true
exclude = [
'^build/',
'^dist/',
]
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import pytest

import mycli.sqlexecute
Expand Down
2 changes: 2 additions & 0 deletions test/features/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import pymysql


Expand Down
2 changes: 2 additions & 0 deletions test/features/environment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os
import shutil
import sys
Expand Down
2 changes: 2 additions & 0 deletions test/features/fixture_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os


Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/auto_vertical.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

from textwrap import dedent

from behave import then, when
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/basic_commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Steps for behavioral style tests are defined in this module.

Each step is defined by the string decorating it. This string is used
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/connection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import io
import os

Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/crud_database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Steps for behavioral style tests are defined in this module.

Each step is defined by the string decorating it. This string is used
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/crud_table.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Steps for behavioral style tests are defined in this module.

Each step is defined by the string decorating it. This string is used
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/iocommands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import os
from textwrap import dedent

Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/named_queries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Steps for behavioral style tests are defined in this module.

Each step is defined by the string decorating it. This string is used
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/specials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Steps for behavioral style tests are defined in this module.

Each step is defined by the string decorating it. This string is used
Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import shlex


Expand Down
2 changes: 2 additions & 0 deletions test/features/steps/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

import re
import sys
import textwrap
Expand Down
3 changes: 2 additions & 1 deletion test/features/wrappager.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

import sys


def wrappager(boundary):
def wrappager(boundary: str) -> None:
print(boundary)
while 1:
buf = sys.stdin.read(2048)
Expand Down
2 changes: 2 additions & 0 deletions test/test_clistyle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# type: ignore

"""Test the mycli.clistyle module."""

from pygments.style import Style
Expand Down
Loading