Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/static-analysis-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox
python -m pip install tox coverage[toml]

- name: Lint with flake8
run: tox -e flake8

- name: Format with black
run: tox -e black

- name: Py 2 and 3 compatibility
run: tox -e modernize


test:
# We want to run on external PRs, but not on our own internal PRs as they'll
Expand All @@ -49,9 +46,9 @@ jobs:

strategy:
matrix:
os: ['ubuntu-latest']
os: ['ubuntu-latest', 'windows-latest']
python: ['3.8', '3.9', '3.10', '3.11']
# Works around the depreciation of python 3.6, 3.7 for ubuntu
# Works around the depreciation of python 3.7 for ubuntu
# https://github.com/actions/setup-python/issues/544
include:
- os: 'ubuntu-22.04'
Expand Down Expand Up @@ -85,7 +82,6 @@ jobs:
include-hidden-files: true
retention-days: 1


coverage:
# We want to run on external PRs, but not on our own internal PRs as they'll
# be run by the push to the branch. Without this if check, checks are
Expand Down
11 changes: 5 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
ci:
autoupdate_schedule: quarterly
skip: [black, flake8]

repos:

- repo: https://github.com/psf/black
Expand All @@ -12,14 +16,9 @@ repos:
- id: flake8
additional_dependencies:
- flake8-bugbear==22.12.6
- Flake8-pyproject
- pep8-naming==0.13.3

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
args: [--min-py3-version=3.6]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ A set of GitHub Action workflows are in place to perform the following style and

**Styling**

Styling or linting is performed via [flake8] along with the plugins [flake8-bugbear] & [pep8-naming]. A minor amount of configuration has been added to _[setup.cfg]_ in order to provide better compatibility with our formatter black (see next section).
Styling or linting is performed via [flake8] along with the plugins [flake8-bugbear], [Flake8-pyproject] & [pep8-naming]. A minor amount of configuration has been added to _[pyproject.toml]_ in order to provide better compatibility with our formatter black (see next section).

**Formatting**

Expand All @@ -69,8 +69,9 @@ Releases are made manually by project managers and will automatically be uploade

[flake8]: https://github.com/PyCQA/flake8
[flake8-bugbear]: https://github.com/PyCQA/flake8-bugbear
[Flake8-pyproject]: https://github.com/john-hen/Flake8-pyproject
[pep8-naming]: https://github.com/PyCQA/pep8-naming
[setup.cfg]: https://github.com/blurstudio/preditor/blob/master/setup.cfg
[pyproject.toml]: https://github.com/blurstudio/hab/blob/master/pyproject.toml
[black]: https://github.com/psf/black
[Issues]: https://github.com/blurstudio/preditor/issues
[create a new issue]: https://github.com/blurstudio/preditor/issues/new
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ The more mature QScintilla workbox requires a few extra dependencies that must
be passed manually. It hasn't been added to `extras_require` because we plan to
split it into its own pip module due to it requiring PyQt5 which is a little hard
to get working inside of DCC's that ship with PySide2 by default. Here is the
python 3 pip install command(For python 2 you will need to compile QScintilla
yourself.)
python 3 pip install command.

- `pip install preditor PyQt5, QScintilla>=2.11.4 aspell-python-py3`

Expand Down
7 changes: 1 addition & 6 deletions preditor/about_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
import textwrap

import six
from future.utils import with_metaclass

import preditor
Expand Down Expand Up @@ -52,11 +51,7 @@ def generate(cls, instance=None):
text = plug.text()
except Exception as error:
text = "Error processing: {}".format(error)
if six.PY3:
text = textwrap.indent(text, cls.indent)
else:
text = ['{}{}'.format(cls.indent, line) for line in text.split('\n')]
text = "\n".join(text)
text = textwrap.indent(text, cls.indent)

# Build the output string including the version information if provided.
if version is not None:
Expand Down
14 changes: 3 additions & 11 deletions preditor/delayable_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,13 @@
import warnings
import weakref
from collections import OrderedDict
from collections.abc import MutableSet

import six
from Qt import QtCompat
from Qt.QtCore import QObject, QTimer, Signal

from .delayables import Delayable

try:
from collections.abc import MutableSet
except ImportError:
# Due to the older versions of six installed by default with DCC's like
# Maya 2020, we can't rely on six.moves.collections_abc, so handle
# the py 2.7 import
from collections import MutableSet


# https://stackoverflow.com/a/7829569
class OrderedSet(MutableSet):
Expand Down Expand Up @@ -108,7 +100,7 @@ def add_delayable(self, delayable):
Raises:
KeyError: A invalid key identifier string was passed.
"""
if isinstance(delayable, six.string_types):
if isinstance(delayable, str):
if delayable in self.delayables:
# Don't replace the instance if a string is passed
return
Expand Down Expand Up @@ -276,7 +268,7 @@ def remove_delayable(self, delayable):
delayable (Delayable or str): A Delayable instance or the key identifier.
Remove this delayable from the current documents if it was added.
"""
if isinstance(delayable, six.string_types):
if isinstance(delayable, str):
if delayable not in self.delayables:
return
delayable = self.delayables[delayable]
Expand Down
3 changes: 1 addition & 2 deletions preditor/gui/group_tab_widget/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import re

import six
from Qt.QtCore import Qt
from Qt.QtGui import QIcon
from Qt.QtWidgets import QHBoxLayout, QMessageBox, QToolButton, QWidget
Expand Down Expand Up @@ -104,7 +103,7 @@ def add_new_tab(self, group, title="Workbox", group_fmt=None):
if isinstance(group, int):
group_title = self.tabText(group)
parent = self.widget(group)
elif isinstance(group, six.string_types):
elif isinstance(group, str):
group_title = group
index = self.index_for_text(group)
if index != -1:
Expand Down
6 changes: 1 addition & 5 deletions preditor/gui/level_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import types
from functools import partial

import six
from Qt.QtGui import QIcon
from Qt.QtWidgets import QAction, QMenu, QToolButton

Expand Down Expand Up @@ -182,10 +181,7 @@ def setLevel(self, level):
# Emit our signal
self.level_changed.emit(level=level)

if six.PY3:
root.setLevel = types.MethodType(setLevel, root)
else:
root.setLevel = types.MethodType(setLevel, root, type(root))
root.setLevel = types.MethodType(setLevel, root)

return root

Expand Down
5 changes: 2 additions & 3 deletions preditor/gui/loggerwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from functools import partial

import __main__
import six
from Qt import QtCompat, QtCore, QtWidgets
from Qt.QtCore import QByteArray, Qt, QTimer, Signal, Slot
from Qt.QtGui import QCursor, QFont, QIcon, QTextCursor
Expand Down Expand Up @@ -428,7 +427,7 @@ def workbox_for_name(cls, name, show=False, visible=False):
workbox = logger.current_workbox()

# If name is a string, find first tab with that name
elif isinstance(name, six.string_types):
elif isinstance(name, str):
split = name.split('/', 1)
if len(split) < 2:
return None
Expand Down Expand Up @@ -792,7 +791,7 @@ def recordPrefs(self, manual=False):
'wordWrap': self.uiWordWrapACT.isChecked(),
'clearBeforeRunning': self.uiClearBeforeRunningACT.isChecked(),
'uiSelectTextACT': self.uiSelectTextACT.isChecked(),
'toolbarStates': six.text_type(self.saveState().toHex(), 'utf-8'),
'toolbarStates': str(self.saveState().toHex(), 'utf-8'),
'consoleFont': self.console().font().toString(),
'uiAutoSaveSettingssACT': self.uiAutoSaveSettingssACT.isChecked(),
'uiAutoPromptACT': self.uiAutoPromptACT.isChecked(),
Expand Down
20 changes: 4 additions & 16 deletions preditor/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import logging

import six

if six.PY3:
from importlib_metadata import EntryPoint, entry_points
else:
import pkg_resources
from importlib_metadata import EntryPoint, entry_points

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -109,12 +104,8 @@ def logging_handlers(self, name=None):
@classmethod
def iterator(cls, group=None, name=None):
"""Iterates over the requested entry point yielding results."""
if six.PY3:
for ep in entry_points().select(group=group):
yield ep
else:
for ep in pkg_resources.iter_entry_points(group, name=name):
yield ep
for ep in entry_points().select(group=group):
yield ep

@classmethod
def from_string(cls, value, name="", group=""):
Expand All @@ -123,8 +114,5 @@ def from_string(cls, value, name="", group=""):
Example:
cls = from_string("preditor.gui.errordialog:ErrorDialog")
"""
if six.PY3:
ep = EntryPoint(name=name, value=value, group=group)
else:
ep = pkg_resources.EntryPoint(name, value)
ep = EntryPoint(name=name, value=value, group=group)
return ep.load()
3 changes: 1 addition & 2 deletions preditor/scintilla/documenteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from contextlib import contextmanager
from functools import partial

import six
from PyQt5.Qsci import QsciScintilla
from PyQt5.QtCore import QTextCodec
from Qt import QtCompat
Expand Down Expand Up @@ -284,7 +283,7 @@ def commentToggle(self, doWhich=None):
"""

# If called by 'triggered' signal, clear out passed argument.
if not isinstance(doWhich, six.string_types):
if not isinstance(doWhich, str):
doWhich = None

comment, result = self.commentCheck()
Expand Down
Loading