Python OOP Companion: The Essential Plugin for Pycharm and IntelliJ

Ever felt that working with Object-Oriented Programming (OOP) in Python could use a bit more flair? A hint more automation, perhaps? Enter the Python OOP Companion!

a year ago   •   3 min read

By Benjamin Justice

Introduction

Ever felt that working with Object-Oriented Programming (OOP) in Python could use a bit more flair? A hint more automation, perhaps? Enter the Python OOP Companion!

What is Python OOP Companion?

It's a nifty plugin tailored for IDEs like Pycharm and IntelliJ. If you've been swimming in the Python OOP waters, this plugin is your lifeguard on duty (Available on Jetbrains Marketplace)

Why use another Pycharm plugin?

You might wonder, with all the tools available, why go for another? Well...

Synchronizing file and class names

Remember TypeScript, where file names are in sync with class names? Such synchronicity is often missing in Python. Python OOP Companion brings this harmony into the Python universe.

The Python OOP Companion is offering to rename the file "customer.py" to "user_account.py" to match the class name "UserAccount" within the file.

Interface validation in Pycharm

Who hasn't grumbled about the missing interface validation in Pycharm, especially with classes inheriting from abc.ABC? This plugin fills that gap beautifully.

The Python OOP Companion marks the "ThingDataInterface" as warning, because the user has configured "Interface" as interface suffix. ThingDataInterface matches the suffix, but does not inherit from ABC

The Development Journey

The backstory of any invention is as fascinating as the invention itself. Curious how this plugin came into existence?

The Birth of the Idea at Intenics Hackathon

Internal company hackathons at Intenics were the cradle of this plugin. On one such spirited event, the prototype of Python OOP Companion was born. It was raw, supported only a single class in a file, and had zero settings. But it was a promising start!

Iterative Improvement and Feedback Gathering

Another round of the Intenics Hackathon was dedicated to refining the plugin. Colleague feedback was the goldmine that helped prioritize features. The end goal? A polished, efficient, user-friendly tool.

Leveraging IntelliJ's Capabilities

When sculpting this masterpiece, the underlying IntelliJ features were the chisel and hammer. They played a pivotal role in bringing the envisioned features to life.

Setting Up the Plugin

Ready to harness the magic? Let's set you up!

Installation

Simply head over to the Jetbrains Marketplace and grab the plugin.

Configuration

Navigate to Settings -> Other Settings -> Python OOP Companion. It's crucial to add your exclusion rules and, if you have any, interface naming conventions. And... you're all set!

Available settings for Python OOP Companion. Every inspection can be enabled/disabled individually. They are described in detail below.

Delve into the Features

Every feature can be enabled/disabled in the plugins settings. Just choose whatever increases your productivity!

Keeping Files and Classes Synchronized

Gone are the days of manual renaming. This plugin keeps your file names in sync with the classes within.

Abstract Base Class (ABC) Functionality

Ensure all empty methods in your ABC are flagged with @abstractmethod. Consistency is key!

Embracing the "Interface"-based Architecture

Have a preferred Prefix or Suffix for naming Interface classes? Set it up! Make sure ABC classes have the proper Interface naming and inherit from ABC.

Interface naming conventions can be configured with a Prefix or a Suffix. These are required for ABC validations

Excluding Paths from Validation

No more accidental validation of virtualenv, third-party code, or scripts. Exclude paths using strings, glob patterns, or even regex!

Exclusion patterns can be configured as "exact match", glob or regex patterns.

Conclusion

The Python OOP Companion is not just a plugin; it's the bridge to a smoother, efficient OOP experience in Python. It was crafted with care, molded with feedback, and perfected with IntelliJ's capabilities. So, why wait? Enhance your Python OOP journey today!

FAQs

  1. What IDEs is Python OOP Companion compatible with?
    • It's tailored for Pycharm and IntelliJ.
  2. Where can I install the plugin?
  3. How do I configure the plugin?
    • Access Settings -> Other Settings -> Python OOP Companion in your IDE.
  4. Can I exclude specific paths from validation?
    • Absolutely! Use strings, glob patterns, or regex to define exclusions.
  5. Is the plugin only for those who practice OOP in Python?
    • While it's specifically designed for OOP, any Python developer can benefit from its features.

Spread the word