Skip to content

Commit 248da22

Browse files
committed
typehint main.py, with consequent fixes elsewhere
* typehint >50% of main.py * requiring additional hints and fixes in config.py and sqlexecute.py * typehint unhinted portions of sqlexecute.py * remove @export decorator and import explicitly into "special" * recast some uninformative variable names * assert that a connection is available before using it * take more care with: ssl config, port, and ssh_port types/defaults before creating a connection * local_infile is a boolean, not a string * ensure get_password_from_file() returns a value * assert that a PromptSession is available before invoking methods on it * set a fallback col/row size in case a prompt session is not available * declare and type self.conn in SQLExecute much earlier * take more care to distinguish falsey values from Nones in SQLExecute connect() * improve defaults passed to pymysql.connect(), matching them to the pymysql docs * test that self.conn is not None rather than checking for a "conn" attribute, before invoking close() * update changelog
1 parent b3385a1 commit 248da22

File tree

7 files changed

+285
-211
lines changed

7 files changed

+285
-211
lines changed

changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
Unreleased
1+
Upcoming Release (TBD)
2+
======================
3+
4+
Internal
5+
--------
6+
* Continue typehinting the non-test codebase.
7+
8+
9+
1.37.1 (2025/07/28)
210
======================
311

412
Internal
@@ -7,6 +15,7 @@ Internal
715
* Align LICENSE with SPDX format.
816
* Fix deprecated `license` specification format in `pyproject.toml`.
917

18+
1019
1.37.0 (2025/07/28)
1120
======================
1221

mycli/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from os.path import exists
99
import struct
1010
import sys
11-
from typing import IO, BinaryIO, Literal
11+
from typing import IO, BinaryIO, Literal, TextIO
1212

1313
from configobj import ConfigObj, ConfigObjError
1414
import pyaes
@@ -25,7 +25,7 @@ def log(logger: logging.Logger, level: int, message: str) -> None:
2525
logger.log(level, message)
2626

2727

28-
def read_config_file(f: str | TextIOWrapper, list_values: bool = True) -> ConfigObj | None:
28+
def read_config_file(f: str | TextIO | TextIOWrapper, list_values: bool = True) -> ConfigObj | None:
2929
"""Read a config file.
3030
3131
*list_values* set to `True` is the default behavior of ConfigObj.
@@ -52,7 +52,7 @@ def read_config_file(f: str | TextIOWrapper, list_values: bool = True) -> Config
5252
return config
5353

5454

55-
def get_included_configs(config_file: str | TextIOWrapper) -> list[str]:
55+
def get_included_configs(config_file: str | TextIOWrapper) -> list[str | TextIOWrapper]:
5656
"""Get a list of configuration files that are included into config_path
5757
with !includedir directive.
5858
@@ -64,7 +64,7 @@ def get_included_configs(config_file: str | TextIOWrapper) -> list[str]:
6464
"""
6565
if not isinstance(config_file, str) or not os.path.isfile(config_file):
6666
return []
67-
included_configs = []
67+
included_configs: list[str | TextIOWrapper] = []
6868

6969
try:
7070
with open(config_file) as f:
@@ -80,7 +80,7 @@ def get_included_configs(config_file: str | TextIOWrapper) -> list[str]:
8080
return included_configs
8181

8282

83-
def read_config_files(files: list[str], list_values: bool = True) -> ConfigObj:
83+
def read_config_files(files: list[str | TextIOWrapper], list_values: bool = True) -> ConfigObj:
8484
"""Read and merge a list of config files."""
8585

8686
config = create_default_config(list_values=list_values)

0 commit comments

Comments
 (0)