Skip to content

pratikmandge/Python-Lint-Fixer

Repository files navigation

🐍 Python Lint Fixer

Version License VS Code

A comprehensive Python linting and formatting extension for Visual Studio Code that enforces consistent code style and automatically fixes common issues.

Python Lint Fixer Demo

✨ Features

🎯 Smart Import Organization

  • System β†’ External β†’ Project import grouping
  • Automatic sorting and deduplication
  • Proper spacing between import groups
  • Multi-line import support with parentheses

πŸ”§ Code Formatting

  • Quote standardization (double to single quotes)
  • Line length management (85 characters with smart wrapping)
  • Function/class formatting with proper indentation
  • Spacing rules (2 lines before classes, 1 line before methods)

πŸš€ Real-time Linting

  • Green highlighting for issues in the editor
  • Hover messages with detailed explanations
  • Problems panel integration
  • Auto-fix on save (configurable)

🎨 User Experience

  • Status bar button for quick access
  • Keyboard shortcuts (Ctrl+Shift+Q)
  • Context menu integration
  • Progress indicators during formatting

πŸš€ Quick Start

Installation

  1. Download the VSIX file from releases
  2. Install in VS Code:
    code --install-extension python-lint-fixer-0.1.0.vsix
  3. Reload VS Code and open a Python file
  4. Click the lightbulb button in the status bar or press Ctrl+Shift+Q

Usage

Before:

import random,math
def generate_values():
    for i in range(0,10):print(i*random.random())
class Dummy:pass

After:

import math
import random


def generate_values():
    for i in range(0, 10):
        print(i * random.random())


class Dummy:
    pass

🎯 Error Codes

Code Description Auto-fixable
PLF001 Line exceeds maximum length βœ…
PLF002 Use single quotes instead of double quotes βœ…
PLF003 Multiple imports should be on separate lines βœ…
PLF004 Classes should be preceded by 2 blank lines βœ…
PLF005 Methods should be preceded by 1 blank line βœ…
PLF006 File should end with a blank line βœ…
PLF007 Import groups should be separated by at least 1 blank line βœ…

πŸ”§ Commands

  • python-lint-fixer.fixFile - Fix current Python file
  • python-lint-fixer.fixWorkspace - Fix all Python files in workspace

⌨️ Keyboard Shortcuts

  • Ctrl+Shift+Q - Fix current Python file (when Python file is active)

🎨 Import Organization Rules

System Imports

import os
import sys
from datetime import datetime

External Libraries

import django
import requests
from flask import Flask

Project Imports (grouped by app)

from users.models import User
from users.views import UserView

from project.models import Project
from project.handlers import ProjectHandler

πŸ› οΈ Development

Prerequisites

  • Node.js (v14 or higher)
  • npm
  • VS Code

Building from Source

  1. Clone the repository:

    git clone <repository-url>
    cd python-lint-fixer
  2. Install dependencies:

    npm install
  3. Compile the extension:

    npm run compile
  4. Package the extension:

    npx vsce package
  5. Install the extension:

    code --install-extension python-lint-fixer-0.1.0.vsix

Project Structure

python-lint-fixer/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ extension.ts          # Main extension entry point
β”‚   β”œβ”€β”€ pythonLinter.ts       # Linting logic and diagnostics
β”‚   └── pythonFormatter.ts    # Auto-fixing functionality
β”œβ”€β”€ test/                     # Test files
β”œβ”€β”€ logo.svg                  # Extension logo
β”œβ”€β”€ package.json              # Extension manifest
β”œβ”€β”€ README.md                 # This file
└── LICENSE                   # MIT License

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


Made with ❀️ by Pratik Mandge

About

Python Lint Fixer is a powerful Visual Studio Code extension designed to automatically format and lint Python code according to industry best practices. Built with TypeScript and the VS Code Extension API, it provides real-time feedback and automatic fixes for common Python coding issues.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors