Skip to content

Commit

Permalink
Replace black/reorder-python-imports by ruff/isort
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Feb 20, 2024
1 parent 0073168 commit ef72391
Show file tree
Hide file tree
Showing 26 changed files with 996 additions and 999 deletions.
71 changes: 27 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,33 @@
repos:
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.1.0]
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.0
hooks:
- id: autoflake
name: autoflake
entry: autoflake --in-place --remove-all-unused-imports
language: python
files: \.py$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.2"
hooks:
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [css, javascript]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.0
hooks:
- id: autoflake
name: autoflake
entry: autoflake --in-place --remove-all-unused-imports
language: python
files: \.py$
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py36-plus]
- repo: local
hooks:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
files: ^(HISTORY.rst|README.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
files: ^(src/|tests/)
args: []
additional_dependencies: [types-attrs]
- repo: local
hooks:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
files: ^(HISTORY.rst|README.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
files: ^(src/|tests/)
args: []
additional_dependencies: [types-attrs]
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"sphinx.ext.autosummary",
]

autodoc_default_flags = ['members']
autodoc_default_flags = ["members"]
autosummary_generate = True
36 changes: 18 additions & 18 deletions examples/drag_and_drop/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create_drag_button(text, qmx_style, parent=None):
button.setText(text)
# # You can set an icon to the button with:
# button.setIcon(...)
button.setProperty('qmx_style', qmx_style)
button.setProperty("qmx_style", qmx_style)
button.setToolTip("Drag me into the graph widget")
return button

Expand All @@ -35,14 +35,14 @@ class DragButton(QPushButton):
def mousePressEvent(self, event):
mime_data = qmxgraph.mime.create_qt_mime_data(
{
'vertices': [
"vertices": [
{
'dx': 0,
'dy': 0,
'width': 120,
'height': 40,
'label': self.text(),
'style': self.property('qmx_style'),
"dx": 0,
"dy": 0,
"width": 120,
"height": 40,
"label": self.text(),
"style": self.property("qmx_style"),
}
]
}
Expand All @@ -63,7 +63,7 @@ class DragAndDropWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)

self.setProperty('name', 'adas')
self.setProperty("name", "adas")
self.setMinimumSize(QSize(640, 480))
self.setWindowTitle("Drag&Drop Styles")

Expand All @@ -72,9 +72,9 @@ def __init__(self):

self.button_pane = QWidget(self)
self.button_pane.setEnabled(False)
red_button = create_drag_button('RED', 'fillColor=#D88', self.button_pane)
green_button = create_drag_button('GREEN', 'fillColor=#8D8', self.button_pane)
blue_button = create_drag_button('BLUE', 'fillColor=#88D', self.button_pane)
red_button = create_drag_button("RED", "fillColor=#D88", self.button_pane)
green_button = create_drag_button("GREEN", "fillColor=#8D8", self.button_pane)
blue_button = create_drag_button("BLUE", "fillColor=#88D", self.button_pane)

self.graph_widget = QmxGraph(parent=central_widget)
self.events_bridge = self.create_events_bridge()
Expand All @@ -96,23 +96,23 @@ def create_events_bridge(self):
# Based in `EventsBridge` docstring.

def on_cells_added_handler(cell_ids):
print(f'added {cell_ids}')
print(f"added {cell_ids}")
qmx = widget.api
for cid in cell_ids:
label = qmx.get_label(cid)
qmx.set_label(cid, f'{label} ({cid})')
qmx.set_label(cid, f"{label} ({cid})")

def on_terminal_changed_handler(cell_id, terminal_type, new_terminal_id, old_terminal_id):
print(
f'{terminal_type} of {cell_id} changed from'
f' {old_terminal_id} to {new_terminal_id}'
f"{terminal_type} of {cell_id} changed from"
f" {old_terminal_id} to {new_terminal_id}"
)

def on_cells_removed_handler(cell_ids):
print(f'removed {cell_ids}')
print(f"removed {cell_ids}")

def on_cells_bounds_changed_handler(changed_cell_bounds):
print(f'cells bounds changed {changed_cell_bounds}')
print(f"cells bounds changed {changed_cell_bounds}")

widget = self.graph_widget
events_bridge = widget.events_bridge
Expand Down
26 changes: 13 additions & 13 deletions examples/styles/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ def __init__(self):
self.setWindowTitle("Qmx Styles")

styles_cfg = {
'round_node': {
'shape': 'ellipse',
'fill_color': '#D88',
'vertical_label_position': 'bottom',
'vertical_align': 'top',
"round_node": {
"shape": "ellipse",
"fill_color": "#D88",
"vertical_label_position": "bottom",
"vertical_align": "top",
},
'bold_edge': {
'end_arrow': 'classic',
'shape': 'connector',
'stroke_width': 5.0,
"bold_edge": {
"end_arrow": "classic",
"shape": "connector",
"stroke_width": 5.0,
},
}

Expand All @@ -48,7 +48,7 @@ def graph_load_handler(self, is_loaded):
width=100,
height=50,
label="BBB",
style='round_node',
style="round_node",
)
# Style by explicit values.
v2_id = qmx.insert_vertex(
Expand All @@ -57,11 +57,11 @@ def graph_load_handler(self, is_loaded):
width=50,
height=100,
label="CCC",
style='fillColor=#8D8',
style="fillColor=#8D8",
)

qmx.insert_edge(source_id=v0_id, target_id=v1_id, label='normal')
qmx.insert_edge(source_id=v1_id, target_id=v2_id, label='bold', style='bold_edge')
qmx.insert_edge(source_id=v0_id, target_id=v1_id, label="normal")
qmx.insert_edge(source_id=v1_id, target_id=v2_id, label="bold", style="bold_edge")


if __name__ == "__main__":
Expand Down
18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[tool.black]
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"setuptools-scm",
]


[tool.ruff]
src = ["src"]
line-length = 100
skip-string-normalization = true

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint.isort]
force-single-line = true
Loading

0 comments on commit ef72391

Please sign in to comment.