Skip to content

Configuring PyCharm

Using PyCharm IDE is mandatory for all team members. It allows to:

  • share configurations across multiple user via .idea folder
  • configure linting, test run and other useful stuff before pushing the code to remote
  • (automatically) rearrange and reformat the code

There's a possible issue with pylint/mypy installation on macos described here.

.idea

.idea folder contains pycharm configurations, including:

├──  common/ # common files and configurations
│
├── .pylintrc # configurations for pylint
├── .pylint.xml # configurations for pylint
├── .mypy.xml # configurations for mypy
│
├── inspectionProfiles/ # folder for storing PyCharm code inspection configurations
│   │
│   ├── profiles_settings.xml
│   ├── Project_Default.xml
│   └── modules.xml
│
├── .gitignore # additional ignore file
│
├── misc.xml # miscellaneous configs
│
├── modules.xml
│
├── Your-project-name.iml # interpreter, documentation settings
│
├── vcs.xml
│
└── Workspace.xml

The .idea folder is created by the lead when starting a new project, and is tracked with git. This will ensure that all team members use the same configurations for environment, documentation style, linters.

Linters

We have two mandatory linters: Pylint and Mypy. Make sure to have both plugins installed in your editor.

After this, you'll see corresponding icons in the toolbar mypy and pylint icons in toolbars

Pylint

Setup guide

  • Linting: Pylint is a widely used Python code static analysis tool. It helps ensure your code conforms to a specific coding style and catches various programming errors, stylistic issues, and potential bugs.
  • Readability: It enforces a set of coding standards (PEP 8, for example) and can highlight areas where your code might be difficult to read or inconsistent.
  • Error Detection: Pylint can catch common programming errors, like undefined variables, unused imports, and other issues that might lead to runtime errors.
  • Customization: You can configure Pylint to suit your preferred coding style and enable/disable specific checks.

mypy

  • Type Checking: Mypy is a static type checker for Python. It helps you catch type-related errors at compile time, even though Python is a dynamically typed language.
  • Type Annotations: Mypy encourages the use of type annotations in your code, making your code more self-documenting and helping you catch type inconsistencies.
  • Better Tooling: By using type annotations and Mypy, you can take advantage of better tooling in modern code editors/IDEs, which can offer improved autocompletion, error highlighting, and type-related suggestions.

Automatic tests and scans

We track the projects in git. We use Pycharms commit tab for committing and pushing the code to the remote. Pycharms version control allows to enable automatic linting, code reformatting and rearrangement, as well as run tests on commit.

To push your changes:

  • Go to commit section from toolbar or by hotkeys(Alt+0 on Ubuntu)
  • Select the files you want to commit changes for
  • Write the commit message in the text box
  • In the right bottom section select all the required settings Commit hooks
  • Click on commit

This will automatically run the scans and report the issues within the project. Carefully review those issues before pushing the code.

Make sure to run the tests for the first time manually so PyCharm starts recognizing them.