You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TinyDB is a very interesting project. The project is well done. Upon reviewing the mypy_plugin.py file, it has a Pylint rating of 2.00/10, indicating multiple areas for improvement. This is just to be more formal with the evaluation. I made a few analyses, and just as a minor improvement, I could suggest, in the hook function inside get_dynamic_class_hook contains type-checking logic that could be error-prone and difficult to maintain. My suggestion is Refactor hook as a separate method, which can make the main logic clearer and easier to debug. For example:
def_hook_logic(ctx: DynamicClassDefContext):
klass=ctx.call.args[0]
ifnotisinstance(klass, NameExpr):
raiseTypeError("Expected a NameExpr instance.")
type_name=klass.fullnameiftype_nameisNone:
raiseValueError("Type name cannot be None.")
qualified=self.lookup_fully_qualified(type_name)
ifqualifiedisNone:
raiseLookupError(f"Failed to find a fully qualified name for {type_name}")
ctx.api.add_symbol_table_node(ctx.name, qualified)
defget_dynamic_class_hook(self, fullname: str) ->CB[DynamicClassDef]:
iffullname=='tinydb.utils.with_typehint':
returnself._hook_logicreturnNone
And thanks for the awesome project!
The text was updated successfully, but these errors were encountered:
Hey @marcfreir, I think that for the MyPy plugin, this is not a big concern. It is a small file (less than 40 lines of code) and does not need active maintenance when working on TinyDB itself. To me, there's not much to be gained by refactoring this file in particular.
Thanks for clarifying that perspective, @msiemens . You're right - given the file's small size and limited maintenance needs, the current implementation is sufficient for its purpose. I appreciate the feedback!
Hello, Markus Siemens & TinyDB team!
The TinyDB is a very interesting project. The project is well done. Upon reviewing the
mypy_plugin.py
file, it has a Pylint rating of 2.00/10, indicating multiple areas for improvement. This is just to be more formal with the evaluation. I made a few analyses, and just as a minor improvement, I could suggest, in thehook
function insideget_dynamic_class_hook
contains type-checking logic that could be error-prone and difficult to maintain. My suggestion is Refactorhook
as a separate method, which can make the main logic clearer and easier to debug. For example:The text was updated successfully, but these errors were encountered: