| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This mssql-python module helps developers set up their development environment for the mssql-python project with automatic code formatting and linting.
For VS Code users - Everything is automated!
Clone the repository
git clone https://github.com/microsoft/mssql-python.git
cd mssql-pythonOpen in VS Code
code .Install recommended extensions
Start coding!
That's it! No manual configuration needed. The repository includes:
This PR adds comprehensive auto-formatting and linting configuration to streamline development:
Purpose: Automatically recommends required VS Code extensions
What it does:
Extensions recommended:
Developer experience:
๐ข VS Code Notification:
"This workspace has extension recommendations.
Would you like to install them?"
[Install All] [Show Recommendations] [Ignore]
Purpose: Pre-configured workspace settings for consistent formatting
What it configures:
Key settings:
{
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnSave": true
},
"black-formatter.args": ["--line-length=100"],
"cpplint.lineLength": 100
}Purpose: C++ code formatting rules (enforced by clang-format)
Configuration:
Purpose: Python linting and formatting configuration
Configuration:
Purpose: Automated CI/CD linting checks on every PR
What it checks:
Workflow triggers:
๐ Zero Manual Setup
๐ Consistent Code Style
๐ Better Code Quality
โก Faster Onboarding
๐ฏ CI/CD Integration
For VS Code users (Recommended):
# Check Python version
python --version
# Check clang-format
clang-format --version
# Check pip
python -m pip --versionThis repository includes .vscode/extensions.json which automatically recommends required extensions when you open the project.
What happens when you open the repo:
The following extensions will be automatically recommended:
If you prefer to install extensions manually:
# Install all extensions at once
code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance
code --install-extension ms-python.black-formatter
code --install-extension ms-python.autopep8
code --install-extension ms-python.pylint
code --install-extension ms-python.flake8
code --install-extension ms-vscode.cpptools
code --install-extension ms-vscode.cpptools-extension-pack
code --install-extension xaver.clang-format
code --install-extension mine.cpplint
code --install-extension github.vscode-pull-request-github
code --install-extension eamodio.gitlensThis repository includes .vscode/settings.json with pre-configured settings for:
Key settings configured:
{
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"black-formatter.args": ["--line-length=100"],
"flake8.args": ["--max-line-length=100"],
"cpplint.lineLength": 100
}# Navigate to project root
cd mssql-python
# Install development dependencies
python -m pip install -r requirements.txt
# This includes:
# - black (code formatter)
# - flake8 (style checker)
# - pylint (linter)
# - autopep8 (formatter)
# - cpplint (C++ linter)
# - mypy (type checker)Once you have the extensions installed and workspace settings loaded:
โ Python Files (.py)
โ C++ Files (.cpp, .c, .h, .hpp)
| File Type | Extensions | Formatter | Line Length | On Save |
|---|---|---|---|---|
| Python | .py | Black | 100 chars | โ Yes |
| C++ Source | .cpp, .c | clang-format | 100 chars | โ Yes |
| C++ Headers | .h, .hpp | clang-format | 100 chars | โ Yes |
The project includes the following configuration files:
Enabled Linters:
Configuration:
Ignored Warnings:
# Common warnings that are ignored:
- E501 (line too long) - Black handles this
- E722 (bare except) - Sometimes necessary
- F401 (unused imports) - May be intentional
- E711/E712 (comparison to None/True/False)View Linting Errors:
Enabled Linter:
Configuration:
Run Manually:
# Check a specific file
python -m cpplint --filter=-legal/copyright,-build/include_subdir,-build/c++11 --linelength=100 mssql_python\pybind\ddbc_bindings.cpp
# Check all C++ files
python -m cpplint --filter=-legal/copyright,-build/include_subdir,-build/c++11 --linelength=100 --recursive mssql_python\pybindThis repository includes .github/workflows/lint-check.yml that automatically checks all PRs for linting issues.
What Gets Checked on Every PR:
โ Required Checks (Must Pass):
โน๏ธ Informational Checks (Won't Block PR):
How It Works:
Run these commands to ensure your PR will pass:
# Format Python files
black --line-length=100 mssql_python/ tests/
# Format C++ files
Get-ChildItem -Path mssql_python\pybind -Recurse -Include *.cpp,*.h,*.hpp | ForEach-Object { clang-format -i $_.FullName }
# Check Python linting
flake8 mssql_python/ tests/ --max-line-length=100
# Check C++ linting
python -m cpplint --filter=-legal/copyright,-build/include_subdir,-build/c++11 --linelength=100 --recursive mssql_python\pybindOr Simply:
The workspace uses Pylance with type checking enabled:
View Type Information:
Example:
# Before save (messy)
def my_function( x,y,z ):
return x+y+z
# After save (formatted)
def my_function(x, y, z):
return x + y + zExample:
// Before save
int value = 42;// Comment too close
// After save
int value = 42; // Comment with 2 spaces| Action | Shortcut |
|---|---|
| Format Document | Shift+Alt+F |
| Format Selection | Ctrl+K Ctrl+F |
| Save (triggers format) | Ctrl+S |
| Problems Panel | Ctrl+Shift+M |
| Command Palette | Ctrl+Shift+P |
| Extensions Panel | Ctrl+Shift+X |
Issue: No prompt to install recommended extensions
Solution:
Issue: Black formatter doesn't run on save
Solution:
Issue: clang-format doesn't run on save
Solutions:
Check clang-format installation:
clang-format --versionVerify extension is active:
Check formatter setting:
Reload VS Code: Ctrl+Shift+P โ "Developer: Reload Window"
Issue: Changes to .vscode/settings.json not taking effect
Solutions:
Issue: No linting errors in Problems panel
Solutions:
python -m flake8 --version
python -m pylint --version
python -m cpplint --versionUnderstanding the hierarchy:
The .vscode/settings.json in this repo will override your personal preferences only for this project.
Before Starting Work:
While Coding:
Before Committing:
Before Creating PR:
โ Automated Setup:
โ Auto-formatting is configured for:
โ Linting is enabled for:
โ CI/CD checks:
โ Type checking is enabled:
Just save your files (Ctrl+S) and everything formats automatically! ๐
| Back | FazBrowse Home | New Git URL |