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
4 changes: 3 additions & 1 deletion .github/workflows/static-analysis-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
- name: Format with black
run: tox -e black

- name: Check imports with deptry
run: tox -e deptry

test:
# We want to run on external PRs, but not on our own internal PRs as they'll
Expand All @@ -47,7 +49,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
python: ['3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
# Works around the depreciation of python 3.7 for ubuntu
# https://github.com/actions/setup-python/issues/544
include:
Expand Down
4 changes: 1 addition & 3 deletions preditor/about_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import sys
import textwrap

from future.utils import with_metaclass

import preditor


class AboutModule(with_metaclass(abc.ABCMeta, object)):
class AboutModule(object, metaclass=abc.ABCMeta):
"""Base class for the `preditor.plug.about_module` entry point. Create a
subclass of this method and expose the class object to the entry point.

Expand Down
4 changes: 2 additions & 2 deletions preditor/cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import absolute_import

import logging
import shutil
import sys
from distutils.spawn import find_executable

import click
from click.core import ParameterSource
Expand Down Expand Up @@ -129,7 +129,7 @@ def shortcut(path, public, name, target, args, description):

# Resolve the full path to the preditor exe.
if target in ("preditor", "preditorw"):
target = find_executable(target)
target = shutil.which(target)

parameter_source = click.get_current_context().get_parameter_source('name')
if parameter_source == ParameterSource.DEFAULT:
Expand Down
16 changes: 6 additions & 10 deletions preditor/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@

import abc
import re
from builtins import str as text
from numbers import Number

from future.utils import iteritems, with_metaclass
from past.builtins import long

# =============================================================================
# CLASSES
# =============================================================================
Expand Down Expand Up @@ -79,7 +75,7 @@ def __str__(cls):
# =============================================================================


class Enum(with_metaclass(abc.ABCMeta, object)):
class Enum(object, metaclass=abc.ABCMeta):
"""A basic enumerator class.

Enumerators are named values that act as identifiers. Typically, a
Expand Down Expand Up @@ -204,9 +200,9 @@ def __eq__(self, value):
return False
if isinstance(value, Enum):
return self.number == value.number
if isinstance(value, (int, long)):
if isinstance(value, int):
return self.number == value
if isinstance(value, str) or isinstance(value, text):
if isinstance(value, str):
if self._compareStr(value):
return True
return False
Expand Down Expand Up @@ -296,7 +292,7 @@ def _compareStr(self, inStr):
# =============================================================================


class EnumGroup(with_metaclass(_MetaEnumGroup, object)):
class EnumGroup(object, metaclass=_MetaEnumGroup):
"""A container class for collecting, organizing, and accessing Enums.

An EnumGroup class is a container for Enum objects. It provides
Expand Down Expand Up @@ -428,7 +424,7 @@ def append(cls, *args, **kwargs):
raise ValueError('Enums given as ordered arguments must have a label.')
for e in args:
setattr(cls, cls._labelToVarName(e.label), e)
for n, e in iteritems(kwargs):
for n, e in kwargs.items():
setattr(cls, n, e)
# reset All and Nothing -- this is necessary so that All is regenerated
# and so that Nothing is not included when finding the member Enums.
Expand Down Expand Up @@ -585,7 +581,7 @@ def __init_enums__(cls):
orderedEnums = sorted(
[
(k, v)
for k, v in iteritems(cls.__dict__)
for k, v in cls.__dict__.items()
if isinstance(v, Enum) and k not in ('All', 'Nothing')
],
key=lambda i: i[1]._creationOrder,
Expand Down
3 changes: 1 addition & 2 deletions preditor/gui/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import sys
import time
import traceback
from builtins import str as text
from functools import partial
from typing import Optional

Expand Down Expand Up @@ -344,7 +343,7 @@ def insertFromMimeData(self, mimeData):
r'\"\<\>\?\`\-\=\[\]\\\;\'\,\.\/ \t\n]'
)
)
newText = text(txt)
newText = str(txt)
for each in exp.findall(newText):
newText = newText.replace(each, '?')

Expand Down
3 changes: 1 addition & 2 deletions preditor/gui/drag_tab_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from functools import partial
from pathlib import Path

import six
from Qt.QtCore import QByteArray, QMimeData, QPoint, QRect, Qt
from Qt.QtGui import QColor, QCursor, QDrag, QPixmap, QRegion
from Qt.QtWidgets import (
Expand Down Expand Up @@ -513,7 +512,7 @@ def save_and_link_file(self, workbox):
filename = workbox.__filename__()
if filename and Path(filename).is_file():
workbox.__set_file_monitoring_enabled__(False)
directory = six.text_type(Path(filename).parent) if filename else ""
directory = str(Path(filename).parent) if filename else ""
success = workbox.__save_as__(directory=directory)
if not success:
return
Expand Down
17 changes: 1 addition & 16 deletions preditor/gui/loggerwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import shutil
import sys
import warnings
from builtins import bytes
from datetime import datetime, timedelta
from enum import IntEnum
from functools import partial
Expand All @@ -25,11 +24,9 @@
QInputDialog,
QMenu,
QMessageBox,
QTextBrowser,
QTextEdit,
QToolButton,
QToolTip,
QVBoxLayout,
)

from .. import (
Expand All @@ -44,7 +41,7 @@
resourcePath,
)
from ..delayable_engine import DelayableEngine
from ..gui import Dialog, Window, handleMenuHovered, loadUi, tab_widget_for_tab
from ..gui import Window, handleMenuHovered, loadUi, tab_widget_for_tab
from ..gui.fuzzy_search.fuzzy_search import FuzzySearch
from ..gui.group_tab_widget.grouped_tab_models import GroupTabListItemModel
from ..logging_config import LoggingConfig
Expand Down Expand Up @@ -302,7 +299,6 @@ def connectSignals(self):
)
self.uiClearBeforeRunningCHK.toggled.connect(self.setClearBeforeRunning)
self.uiEditorVerticalCHK.toggled.connect(self.adjustWorkboxOrientation)
self.uiEnvironmentVarsACT.triggered.connect(self.showEnvironmentVars)
self.uiAboutPreditorACT.triggered.connect(self.show_about)

# Prefs on disk
Expand Down Expand Up @@ -2165,17 +2161,6 @@ def show_about(self):
msg = about_preditor(instance=self)
QMessageBox.information(self, 'About PrEditor', '<pre>{}</pre>'.format(msg))

def showEnvironmentVars(self):
dlg = Dialog(self)
lyt = QVBoxLayout(dlg)
lbl = QTextBrowser(dlg)
lyt.addWidget(lbl)
dlg.setWindowTitle('Blurdev Environment Variable Help')
with open(resourcePath('environment_variables.html')) as f:
lbl.setText(f.read().replace('\n', ''))
dlg.setMinimumSize(600, 400)
dlg.show()

def showEvent(self, event):
super(LoggerWindow, self).showEvent(event)
self.updateIndentationsUseTabs()
Expand Down
1 change: 0 additions & 1 deletion preditor/gui/ui/loggerwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,6 @@ Must be at least 1</string>
</property>
</widget>
<addaction name="uiPreferencesMENU"/>
<addaction name="uiEnvironmentVarsACT"/>
<addaction name="separator"/>
<addaction name="uiAboutPreditorACT"/>
</widget>
Expand Down
9 changes: 5 additions & 4 deletions preditor/osystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import os
import subprocess
import sys
from builtins import str as text

import preditor

Expand Down Expand Up @@ -39,10 +38,10 @@ def getPointerSize():
def pythonPath(pyw=False, architecture=None):
if settings.OS_TYPE != 'Windows':
return 'python'
from distutils.sysconfig import get_python_inc
import sysconfig

# Unable to pull the path from the registry just use the current python path
basepath = os.path.split(get_python_inc())[0]
basepath = os.path.split(sysconfig.get_path('include'))[0]
# build the path to the python executable. If requested use pythonw instead of
# python
return os.path.join(basepath, 'python{w}.exe'.format(w=pyw and 'w' or ''))
Expand Down Expand Up @@ -215,6 +214,8 @@ def normalize(i):

removePaths = set([normalize(x) for x in preditor.core._removeFromPATHEnv])

# TODO: Replace blurpath code with a plugin for reverting process specific
# env var changes when launching a subprocess.
# blurpath records any paths it adds to the PATH variable and other env variable
# modifications it makes, revert these changes.
try:
Expand All @@ -239,7 +240,7 @@ def normalize(i):
]
path = os.path.pathsep.join(paths)
# subprocess does not accept unicode in python 2
if sys.version_info[0] == 2 and isinstance(path, text):
if sys.version_info[0] == 2 and isinstance(path, str):
path = path.encode('utf8')
env['PATH'] = path

Expand Down
12 changes: 5 additions & 7 deletions preditor/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import sys
from pathlib import Path

import six

from . import resourcePath, utils

# cache of all the preferences
Expand Down Expand Up @@ -191,7 +189,7 @@ def create_stamped_path(core_name, filepath, sub_dir='workboxes', time_str=None)

path.parent.mkdir(exist_ok=True)

path = six.text_type(path)
path = str(path)
return path


Expand Down Expand Up @@ -284,7 +282,7 @@ def get_backup_version_info(core_name, workbox_id, versionType, backup_file=None
idx += 1
idx = min(idx, count - 1)

filepath = six.text_type(files[idx])
filepath = str(files[idx])
display_idx = idx + 1
return filepath, display_idx, count

Expand Down Expand Up @@ -322,7 +320,7 @@ def update_pref_args(core_name, pref_dict, old_name, update_data):
orig_pref = pref_dict.pop(old_name)
pref = orig_pref[:] if isinstance(orig_pref, list) else orig_pref

if isinstance(pref, six.text_type):
if isinstance(pref, str):
replacements = update_data.get("replace", [])
for replacement in replacements:
pref = pref.replace(*replacement)
Expand All @@ -332,11 +330,11 @@ def update_pref_args(core_name, pref_dict, old_name, update_data):
newfilepath = create_stamped_path(core_name, pref)
orig_filepath = workbox_dir / orig_pref
if orig_filepath.is_file():
orig_filepath = six.text_type(orig_filepath)
orig_filepath = str(orig_filepath)

if not Path(newfilepath).is_file():
shutil.copy(orig_filepath, newfilepath)
newfilepath = six.text_type(Path(newfilepath).relative_to(workbox_dir))
newfilepath = str(Path(newfilepath).relative_to(workbox_dir))

pref_dict.update({"backup_file": newfilepath})

Expand Down
26 changes: 0 additions & 26 deletions preditor/resource/environment_variables.html

This file was deleted.

6 changes: 1 addition & 5 deletions preditor/scintilla/lang/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

import re
import sys

try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
from configparser import ConfigParser

from .. import Qsci

Expand Down
7 changes: 2 additions & 5 deletions preditor/scintilla/lexers/maxscriptlexer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import absolute_import

import re
from builtins import str as text

from future.utils import iteritems

from .. import Qsci, QsciScintilla

Expand Down Expand Up @@ -35,7 +32,7 @@ def __init__(self, parent=None):
7: 'SmartHighlight',
}

for key, value in iteritems(self._styles):
for key, value in self._styles.items():
setattr(self, value, key)

def description(self, style):
Expand Down Expand Up @@ -214,7 +211,7 @@ def styleText(self, start, end):

# cache objects used by processChunk that do not need updated every time it is
# called
self.hlkwords = set(text(self.keywords(self.SmartHighlight)).lower().split())
self.hlkwords = set(str(self.keywords(self.SmartHighlight)).lower().split())
self.chunkRegex = re.compile('([^A-Za-z0-9]*)([A-Za-z0-9]*)')
kwrds = set(MS_KEYWORDS.split())

Expand Down
6 changes: 1 addition & 5 deletions preditor/settings.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python
from __future__ import absolute_import, print_function

import configparser
import os
import sys

try:
import configparser
except Exception:
import ConfigParser as configparser # noqa: N813

# define the default environment variables
OS_TYPE = ''
if os.name == 'posix':
Expand Down
4 changes: 1 addition & 3 deletions preditor/utils/text_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import re
from collections import deque

from future.utils import with_metaclass


class TextSearch(with_metaclass(abc.ABCMeta, object)):
class TextSearch(object, metaclass=abc.ABCMeta):
"""Base class used to search and markup text for matches to a search term.

Parameters:
Expand Down
Loading