-
Notifications
You must be signed in to change notification settings - Fork 680
Typehint most of main.py, with consequent fixes elsewhere #1300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
25fba82 to
248da22
Compare
248da22 to
7f66c01
Compare
3eaafb7 to
0e37fb3
Compare
0e37fb3 to
5eb91dd
Compare
| 'write_once', | ||
| 'write_pipe_once', | ||
| 'write_tee', | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking question. Do you think we need to hoist all these functions to the top level?
BTW, I'm fine with removing the @export decorator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we do need to hoist. It could be nicer not to.
5eb91dd to
644d682
Compare
* typehint >80% of main.py * requiring additional hints and fixes in config.py, sqlexecute.py, packages/parseutils.py, and others * 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() * remove Python 2.x-compat Unicode literals trick for click * better catch empty database names in change_db() * take more care for edge-case values of text in one_iteration() * don't return None for connection_id_to_kill * clarify overlapping "e" variables * don't use self.sqlexecute when sqlexecute is already available * is_dropping_database() takes a string, not a list * typehint unhinted function in packages/parseutils.py * use only chain() for format_output() output * test isinstance(…, Cursor) rather than hasattr(…, "description") * set start = time() before try block * don't "return output_res(…)" when no return value is expected * update changelog
644d682 to
0261c9b
Compare
Description
main.pyconfig.pyandsqlexecute.py,packages/parseutils.py, and otherssqlexecute.py@exportdecorator and import explicitly intospeciallocal_infileis a boolean, not a stringget_password_from_file()returns a valuePromptSessionis available before invoking methods on itself.conninSQLExecutemuch earlierNones inSQLExecuteconnect()pymysql.connect(), matching them to the pymysql docsself.connis notNonerather than checking for aconnattribute, before invokingclose()change_db()textinone_iteration()Noneforconnection_id_to_killevariablesself.sqlexecutewhensqlexecuteis already availableis_dropping_database()takes a string, not a listpackages/parseutils.pychain()forformat_output()outputisinstance(…, Cursor) rather thanhasattr(…, "description")start = time()beforetryblockreturn output_res(…)when no return value is expected@amjith I tried to keep the cute
@exportdecorator but it is too dynamic for a static checker to understand.Checklist
changelog.md.AUTHORSfile (or it's already there).uv ruff check && uv ruff formatto lint and format the code.