Skip to content
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

Code Quality Improvements Based on Pylint Report #576

Open
marcfreir opened this issue Nov 14, 2024 · 0 comments
Open

Code Quality Improvements Based on Pylint Report #576

marcfreir opened this issue Nov 14, 2024 · 0 comments

Comments

@marcfreir
Copy link

marcfreir commented Nov 14, 2024

Hello, Markus Siemens & TinyDB team!

I ran a Pylint analysis on the TinyDB codebase, and I identified some areas where code quality could be improved. Below is a summary of the findings, of the code block for the function def __repr__(self), along with suggestions for addressing each category. These changes should enhance code readability, maintainability, and adherence to Python's best practices.

Enhanced f-String Usage:

  • Issue: The __repr__ method uses .format(), which can be less readable than f-strings.
  • Suggestion: Replace .format() with f-strings. For example:
    # Current:
    args = [
        'tables={}'.format(list(self.tables())),
        'tables_count={}'.format(len(self.tables())),
        'default_table_documents_count={}'.format(self.__len__()),
        'all_tables_documents_count={}'.format(
            ['{}={}'.format(table, len(self.table(table))) for table in self.tables()]
        ),
    ]
    # Suggested:
    args = [
        f'tables={list(self.tables())}',
        f'tables_count={len(self.tables())}',
        f'default_table_documents_count={self.__len__()}',
        f'all_tables_documents_count={[f"{table}={len(self.table(table))}" for table in self.tables()]}',
    ]

And thanks for the awesome project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant