diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 1677714..0000000 --- a/.coveragerc +++ /dev/null @@ -1,8 +0,0 @@ -[run] -omit = - */tests/* - */vendor/* - */_compat/* - -[report] -show_missing = True diff --git a/.flake8 b/.flake8 index 9fd7e92..c1973de 100644 --- a/.flake8 +++ b/.flake8 @@ -1,12 +1,14 @@ [flake8] ignore = - E731, # do not assign a lambda expression, use a def - W503, # line break before binary operator + # do not assign a lambda expression, use a def + E731, + # line break before binary operator + W503, exclude = .git, - st3/sublime_lib/vendor, .venv, + sublime_lib/vendor, max-line-length = 99 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index cb9629f..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.x - - - name: Install flake8 - run: | - python -m pip install -U pip - pip install flake8 - - - run: flake8 . - - pydocstyle: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: 3.x - - - name: Install pydocstyle - run: | - python -m pip install -U pip - pip install pydocstyle - - - name: Run pydocstyle (allow failure) - run: pydocstyle - working-directory: st3/sublime_lib - continue-on-error: true diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 900d369..6ef5bf1 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -7,29 +7,18 @@ on: jobs: deploy: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: '3.x' + - name: Setup uv + uses: astral-sh/setup-uv@v7 - - name: Install Dependencies - run: | - python -m pip install -U pip - python -m pip install -U sphinx - python -m pip install -U sphinxcontrib.prettyspecialmethods + - name: Install dev dependencies + run: uv sync --group docs - name: Build Docs - run: make -C docs clean html - ## https://github.com/marketplace/actions/sphinx-build - # uses: ammaraskar/sphinx-action@0.3 - # with: - # docs-folder: docs/ - # repo-token: ${{ secrets.GITHUB_TOKEN }} - # build-command: "make clean html" + run: uv run sphinx-build -M html "docs/source/" "docs/" - name: Deploy Docs uses: peaceiris/actions-gh-pages@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3ab3323 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: lint + +on: + push: + branches: + - master + - develop + pull_request: + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Setup uv + uses: astral-sh/setup-uv@v7 + + - name: Install lint dependencies + run: uv sync --group lint + + - name: Run flake8 + run: uv run flake8 sublime_lib + + - name: Run pydocstyle (allow failure) + run: uv run pydocstyle sublime_lib + continue-on-error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..080554f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Publish Release + +on: + push: + tags: + - v* + +jobs: + release: + name: Create and publish release + env: + GH_TOKEN: ${{ github.token }} + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + + - name: Build wheel + run: uv build --wheel + + - name: Create release & upload wheel + run: gh release create --generate-notes --latest -t "$GITHUB_REF_NAME" "$GITHUB_REF_NAME" dist/*.whl diff --git a/.gitignore b/.gitignore index 00ac3f8..68461f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,16 @@ +# caches __pycache__ .mypy_cache -docs/html/ -docs/source/modules/ -*.doctree -*.pickle -modules.rst + +# build artifacts +dist/ +_version.py + +# docs build artifacts +/docs/html/ +/docs/doctrees/ + +# editor files +*.sublime-project +*.sublime-workspace + diff --git a/.sublime-dependency b/.sublime-dependency deleted file mode 100644 index 8a0f05e..0000000 --- a/.sublime-dependency +++ /dev/null @@ -1 +0,0 @@ -01 diff --git a/README.md b/README.md index d46d7a2..5bd02db 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,13 @@ Highlights include: - [`SettingsDict`](https://sublimetext.github.io/sublime_lib/modules/sublime_lib.settings_dict.html), which wraps a `sublime.Settings` object with an interface modeled after a standard Python `dict`. - [`ViewStream`](https://sublimetext.github.io/sublime_lib/modules/sublime_lib.view_stream.html), a standard [Python IO stream](https://docs.python.org/3/library/io.html#io.TextIOBase) wrapping a `sublime.View` object; and [OutputPanel](https://sublimetext.github.io/sublime_lib/modules/sublime_lib.output_panel.html), which extends `ViewStream` to provide additional functionality for output panel views. - The [`syntax` submodule](https://sublimetext.github.io/sublime_lib/modules/sublime_lib.syntax.html), providing methods to list all loaded syntax definitions and to find a syntax matching a given scope. + + +## Releasing a new version + +1. Create a tag in the format `v..` +2. Push the tag to origin. + +A github action should be created that builds a WHEEL file, +creates a release for this tag +and attaches the WHEEL file as an artifact. diff --git a/docs/Makefile b/docs/Makefile index 52ca746..0938487 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -7,7 +7,7 @@ BUILDDIR = . .PHONY: clean html: - sphinx-build -M html "$(SOURCEDIR)" "$(BUILDDIR)" + uv run sphinx-build -M html "$(SOURCEDIR)" "$(BUILDDIR)" clean: rm -rf doctrees html diff --git a/docs/source/conf.py b/docs/source/conf.py index a1887f0..f64466e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../../st3')) +sys.path.insert(0, os.path.abspath('../../sublime_lib')) sys.path.insert(0, os.path.abspath('extensions')) sys.path.insert(0, os.path.abspath('mocks')) diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 8417946..0000000 --- a/mypy.ini +++ /dev/null @@ -1,12 +0,0 @@ -[mypy] -check_untyped_defs = True -disallow_untyped_defs = True -mypy_path = - st3, - stubs, - -[mypy-sublime_lib.vendor.*] -ignore_errors=True - -[mypy-sublime_lib._compat.typing_stubs] -disallow_untyped_defs = False diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d440d5e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,65 @@ +[project] +name = "sublime_lib" +dynamic = ["version"] +description = "Utility library for frequently used functionality in Sublime Text" +readme = "README.md" +license = {file = "LICENSE"} +authors = [{name = "FichteFoll"}, {name = "Thom1729"}] +classifiers = [ + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Python Modules", +] +requires-python = ">=3.8" + +[build-system] +requires = ["hatchling>=1.20", "hatch-vcs>=0.4"] +build-backend = "hatchling.build" + +[dependency-groups] +docs = [ + "sphinx==4.0.2", + "sphinxcontrib-prettyspecialmethods>=0.1.0", +] +lint = [ + "flake8>=3.9.2", + "mypy>=0.720", + "pydocstyle>=4.0.0", +] + +[tool.hatch.build.targets.sdist] +exclude = [ + "/.*", + "/stubs", + "*.lock", +] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "sublime_lib/_version.py" +tag-pattern = "v{version}" + +[tool.coverage.run] +omit = [ + "*/_compat/*", + "*/tests/*", + "*/vendor/*", +] + +[tool.coverage.report] +show_missing = true + +[tool.mypy] +check_untyped_defs = true +disallow_untyped_defs = true +mypy_path = [ + "stubs", + "sublime_lib", +] + +[tool.pydocstyle] +match_dir = "^(?!_)" +match = "^(?!_).*\\.py" diff --git a/st3/.pydocstyle b/st3/.pydocstyle deleted file mode 100644 index 3ec40c2..0000000 --- a/st3/.pydocstyle +++ /dev/null @@ -1,4 +0,0 @@ -[pydocstyle] - -match_dir = ^(?!_) -match = ^(?!_).*\.py diff --git a/st3/sublime_lib/__init__.py b/sublime_lib/__init__.py similarity index 100% rename from st3/sublime_lib/__init__.py rename to sublime_lib/__init__.py diff --git a/st3/sublime_lib/_compat/__init__.py b/sublime_lib/_compat/__init__.py similarity index 100% rename from st3/sublime_lib/_compat/__init__.py rename to sublime_lib/_compat/__init__.py diff --git a/st3/sublime_lib/_compat/enum.py b/sublime_lib/_compat/enum.py similarity index 100% rename from st3/sublime_lib/_compat/enum.py rename to sublime_lib/_compat/enum.py diff --git a/st3/sublime_lib/_compat/pathlib.py b/sublime_lib/_compat/pathlib.py similarity index 100% rename from st3/sublime_lib/_compat/pathlib.py rename to sublime_lib/_compat/pathlib.py diff --git a/st3/sublime_lib/_compat/typing.py b/sublime_lib/_compat/typing.py similarity index 100% rename from st3/sublime_lib/_compat/typing.py rename to sublime_lib/_compat/typing.py diff --git a/st3/sublime_lib/_compat/typing_stubs.py b/sublime_lib/_compat/typing_stubs.py similarity index 100% rename from st3/sublime_lib/_compat/typing_stubs.py rename to sublime_lib/_compat/typing_stubs.py diff --git a/st3/sublime_lib/_util/__init__.py b/sublime_lib/_util/__init__.py similarity index 100% rename from st3/sublime_lib/_util/__init__.py rename to sublime_lib/_util/__init__.py diff --git a/st3/sublime_lib/_util/collections.py b/sublime_lib/_util/collections.py similarity index 100% rename from st3/sublime_lib/_util/collections.py rename to sublime_lib/_util/collections.py diff --git a/st3/sublime_lib/_util/enum.py b/sublime_lib/_util/enum.py similarity index 100% rename from st3/sublime_lib/_util/enum.py rename to sublime_lib/_util/enum.py diff --git a/st3/sublime_lib/_util/glob.py b/sublime_lib/_util/glob.py similarity index 100% rename from st3/sublime_lib/_util/glob.py rename to sublime_lib/_util/glob.py diff --git a/st3/sublime_lib/_util/guard.py b/sublime_lib/_util/guard.py similarity index 100% rename from st3/sublime_lib/_util/guard.py rename to sublime_lib/_util/guard.py diff --git a/st3/sublime_lib/_util/named_value.py b/sublime_lib/_util/named_value.py similarity index 100% rename from st3/sublime_lib/_util/named_value.py rename to sublime_lib/_util/named_value.py diff --git a/st3/sublime_lib/_util/simple_yaml.py b/sublime_lib/_util/simple_yaml.py similarity index 100% rename from st3/sublime_lib/_util/simple_yaml.py rename to sublime_lib/_util/simple_yaml.py diff --git a/st3/sublime_lib/_util/weak_method.py b/sublime_lib/_util/weak_method.py similarity index 100% rename from st3/sublime_lib/_util/weak_method.py rename to sublime_lib/_util/weak_method.py diff --git a/st3/sublime_lib/activity_indicator.py b/sublime_lib/activity_indicator.py similarity index 100% rename from st3/sublime_lib/activity_indicator.py rename to sublime_lib/activity_indicator.py diff --git a/st3/sublime_lib/encodings.py b/sublime_lib/encodings.py similarity index 100% rename from st3/sublime_lib/encodings.py rename to sublime_lib/encodings.py diff --git a/st3/sublime_lib/flags.py b/sublime_lib/flags.py similarity index 99% rename from st3/sublime_lib/flags.py rename to sublime_lib/flags.py index 0027ff5..cd62854 100644 --- a/st3/sublime_lib/flags.py +++ b/sublime_lib/flags.py @@ -39,7 +39,6 @@ from ._compat.typing import Callable, Optional - __all__ = [ 'DialogResult', 'PointClass', 'FindOption', 'RegionOption', 'PopupOption', 'PhantomLayout', 'OpenFileOption', 'QuickPanelOption', diff --git a/st3/sublime_lib/panel.py b/sublime_lib/panel.py similarity index 100% rename from st3/sublime_lib/panel.py rename to sublime_lib/panel.py diff --git a/st3/sublime_lib/region_manager.py b/sublime_lib/region_manager.py similarity index 100% rename from st3/sublime_lib/region_manager.py rename to sublime_lib/region_manager.py diff --git a/st3/sublime_lib/resource_path.py b/sublime_lib/resource_path.py similarity index 100% rename from st3/sublime_lib/resource_path.py rename to sublime_lib/resource_path.py diff --git a/st3/sublime_lib/settings_dict.py b/sublime_lib/settings_dict.py similarity index 99% rename from st3/sublime_lib/settings_dict.py rename to sublime_lib/settings_dict.py index a5158b0..c4f8c73 100644 --- a/st3/sublime_lib/settings_dict.py +++ b/sublime_lib/settings_dict.py @@ -54,7 +54,7 @@ def __eq__(self, other: object) -> bool: and refer to the same underlying settings data. """ return ( - type(self) == type(other) + type(self) is type(other) and isinstance(other, SettingsDict) and self.settings.settings_id == other.settings.settings_id ) diff --git a/st3/sublime_lib/show_selection_panel.py b/sublime_lib/show_selection_panel.py similarity index 100% rename from st3/sublime_lib/show_selection_panel.py rename to sublime_lib/show_selection_panel.py diff --git a/st3/sublime_lib/syntax.py b/sublime_lib/syntax.py similarity index 100% rename from st3/sublime_lib/syntax.py rename to sublime_lib/syntax.py diff --git a/st3/sublime_lib/vendor/__init__.py b/sublime_lib/vendor/__init__.py similarity index 100% rename from st3/sublime_lib/vendor/__init__.py rename to sublime_lib/vendor/__init__.py diff --git a/st3/sublime_lib/vendor/pathlib/LICENSE.txt b/sublime_lib/vendor/pathlib/LICENSE.txt similarity index 100% rename from st3/sublime_lib/vendor/pathlib/LICENSE.txt rename to sublime_lib/vendor/pathlib/LICENSE.txt diff --git a/st3/sublime_lib/vendor/pathlib/__init__.py b/sublime_lib/vendor/pathlib/__init__.py similarity index 100% rename from st3/sublime_lib/vendor/pathlib/__init__.py rename to sublime_lib/vendor/pathlib/__init__.py diff --git a/st3/sublime_lib/vendor/pathlib/pathlib.py b/sublime_lib/vendor/pathlib/pathlib.py similarity index 100% rename from st3/sublime_lib/vendor/pathlib/pathlib.py rename to sublime_lib/vendor/pathlib/pathlib.py diff --git a/st3/sublime_lib/vendor/pathlib/test_pathlib.py b/sublime_lib/vendor/pathlib/test_pathlib.py old mode 100755 new mode 100644 similarity index 100% rename from st3/sublime_lib/vendor/pathlib/test_pathlib.py rename to sublime_lib/vendor/pathlib/test_pathlib.py diff --git a/st3/sublime_lib/vendor/python/LICENSE b/sublime_lib/vendor/python/LICENSE similarity index 100% rename from st3/sublime_lib/vendor/python/LICENSE rename to sublime_lib/vendor/python/LICENSE diff --git a/st3/sublime_lib/vendor/python/README b/sublime_lib/vendor/python/README similarity index 100% rename from st3/sublime_lib/vendor/python/README rename to sublime_lib/vendor/python/README diff --git a/st3/sublime_lib/vendor/python/__init__.py b/sublime_lib/vendor/python/__init__.py similarity index 100% rename from st3/sublime_lib/vendor/python/__init__.py rename to sublime_lib/vendor/python/__init__.py diff --git a/st3/sublime_lib/vendor/python/enum.py b/sublime_lib/vendor/python/enum.py similarity index 100% rename from st3/sublime_lib/vendor/python/enum.py rename to sublime_lib/vendor/python/enum.py diff --git a/st3/sublime_lib/vendor/python/types.py b/sublime_lib/vendor/python/types.py similarity index 100% rename from st3/sublime_lib/vendor/python/types.py rename to sublime_lib/vendor/python/types.py diff --git a/st3/sublime_lib/view_stream.py b/sublime_lib/view_stream.py similarity index 100% rename from st3/sublime_lib/view_stream.py rename to sublime_lib/view_stream.py diff --git a/st3/sublime_lib/view_utils.py b/sublime_lib/view_utils.py similarity index 100% rename from st3/sublime_lib/view_utils.py rename to sublime_lib/view_utils.py diff --git a/st3/sublime_lib/window_utils.py b/sublime_lib/window_utils.py similarity index 100% rename from st3/sublime_lib/window_utils.py rename to sublime_lib/window_utils.py diff --git a/unittesting.json b/unittesting.json deleted file mode 100644 index 5fcf8eb..0000000 --- a/unittesting.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "deferred": true -}