Skip to content

Commit

Permalink
chore: miscellaneous updates, update linting rules (pymmcore-plus#161)
Browse files Browse the repository at this point in the history
* remove old

* update pre-commit

* new ruff rules

* update readme

* newline

* remove direct refs

* resort

* misc
  • Loading branch information
tlambert03 authored Jul 29, 2023
1 parent 216ddd8 commit 8092d15
Show file tree
Hide file tree
Showing 33 changed files with 119 additions and 207 deletions.
22 changes: 0 additions & 22 deletions .cruft.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
user=fdrgsp
user=pymmcore-plus
project=pymmcore-widgets
issues=false
exclude-labels=duplicate,question,invalid,wontfix,hide
Expand Down
22 changes: 6 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,20 @@ ci:
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"

default_install_hook_types: [pre-commit, commit-msg]

repos:
# - repo: https://github.com/compilerla/conventional-pre-commit
# rev: v1.3.0
# hooks:
# - id: conventional-pre-commit
# stages: [commit-msg]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
- repo: https://github.com/crate-ci/typos
rev: v1.16.1
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace
- id: typos

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.275
rev: v0.0.280
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black

Expand All @@ -41,4 +31,4 @@ repos:
- id: mypy
files: "^src/"
additional_dependencies:
- pymmcore-plus>=0.6.6
- pymmcore-plus >=0.7.1
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# pymmcore-widgets

[![License](https://img.shields.io/pypi/l/pymmcore-widgets.svg?color=green)](https://github.com/pymmcore-plus/pymmcore-widgets/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/pymmcore-widgets.svg?color=green)](https://pypi.org/project/pymmcore-widgets)
[![Python Version](https://img.shields.io/pypi/pyversions/pymmcore-widgets.svg?color=green)](https://python.org)
[![PyPI](https://img.shields.io/pypi/v/pymmcore-widgets.svg?color=green)](https://pypi.org/project/pymmcore-widgets)
[![Conda](https://img.shields.io/conda/vn/conda-forge/pymmcore-widgets)](https://anaconda.org/conda-forge/pymmcore-widgets)
[![CI](https://github.com/pymmcore-plus/pymmcore-widgets/actions/workflows/ci.yml/badge.svg)](https://github.com/pymmcore-plus/pymmcore-widgets/actions/workflows/ci.yml)
[![docs](https://github.com/pymmcore-plus/pymmcore-plus/actions/workflows/docs.yml/badge.svg)](https://pymmcore-plus.github.io/pymmcore-widgets/)
[![codecov](https://codecov.io/gh/pymmcore-plus/pymmcore-widgets/branch/main/graph/badge.svg)](https://codecov.io/gh/pymmcore-plus/pymmcore-widgets)

A set of widgets for the [pymmcore-plus](https://github.com/pymmcore-plus/pymmcore-plus) package.
Expand Down
2 changes: 1 addition & 1 deletion examples/mda_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self) -> None:
self.mmc.mda.events.sequenceFinished.connect(self._on_end)
self.mmc.mda.events.sequencePauseToggled.connect(self._on_pause)

# instantiate the MDAWidget, and a couple lables for feedback
# instantiate the MDAWidget, and a couple labels for feedback
self.mda = MDAWidget(include_run_button=True)
self.current_sequence = QLabel('... enter info and click "Run"')
self.current_event = QLabel("... current event info will appear here")
Expand Down
113 changes: 49 additions & 64 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# https://peps.python.org/pep-0517/
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools-scm>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

# https://hatch.pypa.io/latest/config/metadata/
[tool.hatch.version]
source = "vcs"

# https://hatch.pypa.io/latest/config/build/#file-selection
[tool.hatch.build.targets.sdist]
include = ["/src", "/tests"]

[tool.hatch.build.targets.wheel]
only-include = ["src"]
sources = ["src"]

# https://peps.python.org/pep-0621/
[project]
Expand All @@ -17,19 +29,29 @@ authors = [
]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: X11 Applications :: Qt",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python",
"Topic :: Software Development :: Widget Sets",
"Topic :: System :: Hardware :: Hardware Drivers",
"Topic :: System :: Hardware",
"Topic :: Utilities",
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = [
'pymmcore-plus>=0.6.6',
'useq-schema >=0.2.0',
'superqt[quantity] >=0.3.1',
'fonticon-materialdesignicons6',
'qtpy',
'pymmcore-plus >=0.7.1',
'qtpy >=2.0',
'superqt[quantity] >=0.3.1',
'useq-schema >=0.3.1',
]

# extras
Expand Down Expand Up @@ -60,55 +82,33 @@ docs = [
"mkdocs-material",
"mkdocstrings-python",
"mkdocs-literate-nav",
"mkdocs-gen-files"
"mkdocs-gen-files",
]

[project.urls]
homepage = "https://github.com/pymmcore-plus/pymmcore-widgets"
repository = "https://github.com/pymmcore-plus/pymmcore-widgets"

# same as console_scripts entry point
# [project.scripts]
# spam-cli = "spam:main_cli"

# Entry points
# https://peps.python.org/pep-0621/#entry-points
# [project.entry-points."spam.magical"]
# tomatoes = "spam:main_tomatoes"

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[tool.setuptools]
zip-safe = false
include-package-data = true
packages = { find = { where = ["src"], exclude = [] } }
Homepage = "https://github.com/pymmcore-plus/pymmcore-widgets"
"Source Code" = "https://github.com/pymmcore-plus/pymmcore-widgets"
Documentation = "https://pymmcore-plus.github.io/pymmcore-widgets"

[tool.setuptools.package-data]
"*" = ["py.typed"]

# https://github.com/pypa/setuptools_scm/#pyprojecttoml-usage
[tool.setuptools_scm]

# https://pycqa.github.io/isort/docs/configuration/options.html
[tool.isort]
profile = "black"

# https://github.com/charliermarsh/ruff
# https://beta.ruff.rs/docs/rules/
[tool.ruff]
line-length = 88
target-version = "py38"
src = ["src","tests"]
extend-select = [
src = ["src", "tests"]
select = [
"E", # style errors
"F", # flakes
"W", # warnings
"D", # pydocstyle
"I001", # isort
"UP", # pyupgrade
# "N", # pep8-naming
# "S", # bandit
"C4", # flake8-comprehensions
"I", # isort
"UP", # pyupgrade
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"A001", # flake8-builtins
"RUF", # ruff-specific rules
"TID", # tidy
"TCH", # typecheck
# "SLF", # private-access
]
ignore = [
"D100", # Missing docstring in public module
Expand All @@ -119,21 +119,16 @@ ignore = [
"D401", # First line should be in imperative mood
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
"C901", # Function is too complex
]


[tool.ruff.per-file-ignores]
"tests/*.py" = ["D"]
"tests/*.py" = ["D", "SLF"]

# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests"]
filterwarnings = [
"error",
"ignore:distutils Version classes are deprecated"
]
filterwarnings = ["error", "ignore:distutils Version classes are deprecated"]

# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
Expand All @@ -153,30 +148,20 @@ exclude_lines = [
"if TYPE_CHECKING:",
"@overload",
"except ImportError",
"raise AssertionError",
"if __name__ == .__main__.:",
"raise NotImplementedError",
]

# https://github.com/cruft/cruft
[tool.cruft]
skip = ["tests"]
[tool.coverage.run]
source = ['pymmcore_widgets']

# https://github.com/mgedmin/check-manifest#configuration
[tool.check-manifest]
ignore = [
".cruft.json",
".flake8",
".github_changelog_generator",
".pre-commit-config.yaml",
"tests/**/*",
"docs/**/*",
"mkdocs.yml",
"tox.ini",
"examples/**/*",
]

# https://python-semantic-release.readthedocs.io/en/latest/configuration.html
[tool.semantic_release]
version_source = "tag_only"
branch = "main"
changelog_sections = "feature,fix,breaking,documentation,performance,chore,:boom:,:sparkles:,:children_crossing:,:lipstick:,:iphone:,:egg:,:chart_with_upwards_trend:,:ambulance:,:lock:,:bug:,:zap:,:goal_net:,:alien:,:wheelchair:,:speech_balloon:,:mag:,:apple:,:penguin:,:checkered_flag:,:robot:,:green_apple:,Other"
# commit_parser=semantic_release.history.angular_parser
build_command = "pip install build && python -m build"
5 changes: 0 additions & 5 deletions setup.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
)

from pymmcore_widgets._property_widget import PropertyWidget

from .._util import block_core
from pymmcore_widgets._util import block_core


class AddFirstPresetWidget(QDialog):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING

from pymmcore_plus import CMMCorePlus
from qtpy.QtGui import QCloseEvent
from qtpy.QtWidgets import (
QDialog,
QGroupBox,
Expand All @@ -16,11 +16,14 @@
QWidget,
)

from pymmcore_widgets._device_property_table import DevicePropertyTable
from pymmcore_widgets._device_type_filter import DeviceTypeFilters

from .._device_property_table import DevicePropertyTable
from ._add_first_preset_widget import AddFirstPresetWidget

if TYPE_CHECKING:
from qtpy.QtGui import QCloseEvent


class AddGroupWidget(QDialog):
"""Widget to create a new group."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
)

from pymmcore_widgets._property_widget import PropertyWidget

from .._util import block_core
from pymmcore_widgets._util import block_core


class AddPresetWidget(QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

from pymmcore_widgets._device_property_table import DevicePropertyTable
from pymmcore_widgets._device_type_filter import DeviceTypeFilters

from .._util import block_core
from pymmcore_widgets._util import block_core


class EditGroupWidget(QDialog):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
from superqt.utils import signals_blocked

from pymmcore_widgets._property_widget import PropertyWidget

from .._util import block_core
from pymmcore_widgets._util import block_core


class EditPresetWidget(QDialog):
Expand Down Expand Up @@ -193,7 +192,7 @@ def _apply_changes(self) -> None:
if p == self._preset:
return
warnings.warn(
"Threre is already a preset with the same "
"There is already a preset with the same "
f"devices, properties and values: '{p}'.",
stacklevel=2,
)
Expand Down
Loading

0 comments on commit 8092d15

Please sign in to comment.