Skip to content

Conversation

jahnvi480
Copy link
Contributor

@jahnvi480 jahnvi480 commented Sep 3, 2025

Work Item / Issue Reference

AB#38478
AB#33454
AB#36303

GitHub Issue: #22


Summary

This pull request introduces several improvements to code quality enforcement, connection handling, and code clarity across the codebase. The main changes include adding automated linting workflows for Python and C++ code, enhancing connection pooling configuration, improving exception handling and validation, and refining code formatting and documentation.

Automated Code Quality Enforcement:

  • Added a GitHub Actions workflow (.github/workflows/code-quality-check.yml) to automatically run Python (pylint) and C++ (cpplint) linters on pull requests, with clear status reporting and PR commenting for failed checks.
  • Introduced .pre-commit-config.yml to enable pre-commit linting for both Python and C++ files, ensuring code quality before commits are made.
  • Added cpplint.cfg to configure C++ linting rules, such as line length and file exclusions.

Connection and Pooling Enhancements:

  • Improved the pooling function in mssql_python/__init__.py by adding a proper docstring and clarifying default behavior and arguments.
  • Ensured PoolingManager is imported at the module level for better clarity and reliability.

Code Quality, Validation, and Documentation:

  • Added module-level docstrings and validation for bcp_options.py, including improved error messages in BCPOptions and ColumnFormat classes.
  • Refactored mssql_python/auth.py for better formatting, exception handling, and parameter validation, including improved error messages and code style.

Connection Class and Exception Handling:

  • Updated mssql_python/connection.py to import and expose all DB-API 2.0 exception classes as attributes of the Connection class, allowing users to catch exceptions via connection.Error, connection.ProgrammingError, etc.
  • Improved code formatting, type annotations, and logging consistency throughout the Connection class, and clarified weak reference handling for cursors.

@Copilot Copilot AI review requested due to automatic review settings September 3, 2025 07:30
@github-actions github-actions bot added pr-size: large Substantial code update labels Sep 3, 2025
@jahnvi480 jahnvi480 changed the title STYLE: Python code linting STYLE: Code linting Sep 3, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 3, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request focuses on Python code linting and formatting improvements across the mssql-python codebase. The changes enhance code readability, improve parameter naming consistency, and align with Python style guidelines while maintaining functional equivalence.

  • Improves code formatting by breaking long lines and adjusting string quoting style
  • Standardizes parameter naming (e.g., tableTypetable_type)
  • Adds proper module documentation and copyright headers where missing

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_004_cursor.py Updates parameter name from tableType to table_type in cursor.tables() calls
mssql_python/type.py Breaks long function signature and error message formatting into multiple lines
mssql_python/testing_ddbc_bindings.py Removes unused import and reformats long function calls across multiple lines
mssql_python/row.py Adds module header and reformats long lines with proper indentation
mssql_python/pooling.py Adds comprehensive module documentation and docstrings for all methods
mssql_python/mssql_python.pyi Breaks long function signature into multiple lines for better readability
mssql_python/logging_config.py Updates string quoting style and improves code formatting consistency
mssql_python/helpers.py Reorganizes imports and removes inline import statements
mssql_python/exceptions.py Reformats exception instantiation calls for better readability
mssql_python/ddbc_bindings.py Updates string quoting style and reformats conditional logic
mssql_python/db_connection.py Breaks long function signature and adds proper spacing
mssql_python/cursor.py Extensive formatting improvements including line breaks, string quoting, and parameter naming
mssql_python/constants.py Adds spacing between enum class definitions
mssql_python/connection.py Reformats imports, breaks long lines, and improves string quoting consistency
mssql_python/bcp_options.py Adds module header and improves error message formatting
mssql_python/auth.py Reformats imports and improves code formatting throughout
mssql_python/init.py Reorganizes imports and uncomments documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 9, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 9, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 9, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 9, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 9, 2025
@github-actions github-actions bot added the pr-size: large Substantial code update label Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
@github-actions github-actions bot added pr-size: large Substantial code update and removed pr-size: large Substantial code update labels Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-size: large Substantial code update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants