Skip to content

Commit

Permalink
Implement black and isort-based style checks (#549)
Browse files Browse the repository at this point in the history
This PR adds `black` and `isort` style formatting and checking, and
requires future code changes to comply with `black` and `isort` styles.

- New workflow `check-style.yml` that runs `black`, `isort` and `flake8`
checks
- Removes `flake8` check from test workflow
- `etstool.py` support for both checking and fixing style, via new
`style` command (with subcommands `fix` and `check`)
- removed old `flake8` command from `etstool.py`

Note: I'm installing the style-related packages from PyPI in
`etstool.py`, so that `etstool.py` and the new workflow are installing
the same package versions. I'm also fixing black to version 23.x so that
we don't suddenly get style failures for the first Black release in 2024
(or later years) - see Black's stability policy here:
https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy

Closes #527
  • Loading branch information
mdickinson authored Mar 23, 2023
1 parent 5c55463 commit 57d5974
Show file tree
Hide file tree
Showing 189 changed files with 1,373 additions and 1,398 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[flake8]
max-line-length = 79
exclude = build
ignore = E266, W503
ignore = E203, E266, W503
per-file-ignores = */api.py:F401
20 changes: 20 additions & 0 deletions .github/workflows/check-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run style checks

on: [pull_request, workflow_dispatch]

jobs:
style:
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: '.github/workflows/style-requirements.txt'
- run: python -m pip install -r .github/workflows/style-requirements.txt
- run: |
python -m black --check --diff .
python -m isort --check --diff .
python -m flake8 .
4 changes: 4 additions & 0 deletions .github/workflows/style-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
black ~= 23.0
flake8
flake8-ets
isort
3 changes: 0 additions & 3 deletions .github/workflows/test-with-edm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ jobs:
run: python -m pip install -r .github/workflows/bootstrap-requirements.txt
- name: Install test environment
run: python etstool.py install --runtime=${{ matrix.runtime }} --toolkit=${{ matrix.toolkit }}
- name: Flake8
run: python etstool.py flake8 --runtime=${{ matrix.runtime }} --toolkit=${{ matrix.toolkit }}
if: runner.os == 'Linux' && matrix.toolkit == 'null'
- name: Run tests (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: xvfb-run -a python etstool.py test --runtime=${{ matrix.runtime }} --toolkit=${{ matrix.toolkit }}
Expand Down
9 changes: 5 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
.. |Message| replace:: :github-demo:`Message <MOTD/acme/motd/message.py>`
.. |messages.py| replace:: :github-demo:`message.py <MOTD/acme/motd/software_quotes/messages.py>`
.. |Message of the Day| replace:: :github-demo:`Message of the Day <MOTD>`
""" # noqa: E501
""" # noqa: E501

# Options for HTML output
# -----------------------
Expand Down Expand Up @@ -234,7 +234,8 @@
# -- Options for extlinks extension -------------------------------------------

extlinks = {
'github-demo': (
f'https://github.com/enthought/envisage/tree/{version}/envisage/examples/demo/%s', # noqa: E501
'')
"github-demo": (
f"https://github.com/enthought/envisage/tree/{version}/envisage/examples/demo/%s", # noqa: E501
"",
)
}
27 changes: 13 additions & 14 deletions envisage/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@
"""

from .application import Application
from .core_plugin import CorePlugin
from .egg_plugin_manager import EggPluginManager
from .extension_point import ExtensionPoint
from .extension_point_binding import (
bind_extension_point,
ExtensionPointBinding,
unbind_extension_point,
)
from .extension_point_changed_event import ExtensionPointChangedEvent
from .extension_provider import ExtensionProvider
from .extension_registry import ExtensionRegistry
from .i_application import IApplication
from .i_extension_point import IExtensionPoint
from .i_extension_point_user import IExtensionPointUser
Expand All @@ -76,28 +88,15 @@
from .i_plugin_activator import IPluginActivator
from .i_plugin_manager import IPluginManager
from .i_service_registry import IServiceRegistry

from .application import Application
from .core_plugin import CorePlugin
from .egg_plugin_manager import EggPluginManager
from .extension_registry import ExtensionRegistry
from .extension_point import ExtensionPoint
from .extension_point_binding import (
ExtensionPointBinding,
bind_extension_point,
unbind_extension_point,
)
from .extension_provider import ExtensionProvider
from .extension_point_changed_event import ExtensionPointChangedEvent
from .ids import (
BINDINGS,
COMMANDS,
PREFERENCES,
PREFERENCES_CATEGORIES,
PREFERENCES_PANES,
SERVICE_OFFERS,
TASK_EXTENSIONS,
TASKS,
TASK_EXTENSIONS
)
from .import_manager import ImportManager
from .plugin import Plugin
Expand Down
Loading

0 comments on commit 57d5974

Please sign in to comment.