Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 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
8 changes: 0 additions & 8 deletions .coveragerc

This file was deleted.

7 changes: 4 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[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,

max-line-length = 99
68 changes: 48 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,69 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- master
- develop
pull_request:
workflow_dispatch:

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v1
- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: '3.8'

- name: Install flake8
run: |
python -m pip install -U pip
pip install flake8
- name: Setup uv
uses: astral-sh/setup-uv@v7

- run: flake8 .
- name: Install dev dependencies
run: uv sync --group dev

- name: Run flake8
run: uv run flake8 .

pydocstyle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v1
- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.x
python-version: '3.8'

- name: Setup uv
uses: astral-sh/setup-uv@v7

- name: Install pydocstyle
run: |
python -m pip install -U pip
pip install pydocstyle
- name: Install dev dependencies
run: uv sync --group dev

- name: Run pydocstyle (allow failure)
run: pydocstyle
working-directory: st3/sublime_lib
run: uv run pydocstyle src/sublime_lib
continue-on-error: true

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Setup uv
uses: astral-sh/setup-uv@v7

- name: Install dev dependencies
run: uv sync --group dev

- name: Run mypy (allow failure)
run: uv run mypy src
continue-on-error: true
21 changes: 11 additions & 10 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ on:

jobs:
deploy:
runs-on: ubuntu-20.04
name: Create and publish documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v1
- name: Setup Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.8'

- name: Install Dependencies
run: |
python -m pip install -U pip
python -m pip install -U sphinx
python -m pip install -U sphinxcontrib.prettyspecialmethods
- name: Setup uv
uses: astral-sh/setup-uv@v7

- name: Install dev dependencies
run: uv sync --group dev

- name: Build Docs
run: make -C docs clean html
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish Release

on:
workflow_dispatch:

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: |
version=$(uv version --short)
Comment thread
deathaxe marked this conversation as resolved.
gh release create --generate-notes --latest -t "v${version}" "v${version}" dist/*.whl
18 changes: 13 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# caches
__pycache__
.mypy_cache
docs/html/
docs/source/modules/
*.doctree
*.pickle
modules.rst

# build artifacts
dist/

# docs build artifacts
/docs/html/
/docs/doctrees/

# editor files
*.sublime-project
*.sublime-workspace

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
1 change: 0 additions & 1 deletion .sublime-dependency

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ 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. Bump version in `pyproject.toml` & commit it.
3. Push to origin.
4. On GitHub > Actions, run "release" action against `master`.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../st3'))
sys.path.insert(0, os.path.abspath('../../src'))
sys.path.insert(0, os.path.abspath('extensions'))
sys.path.insert(0, os.path.abspath('mocks'))

Expand Down
8 changes: 1 addition & 7 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,5 @@
check_untyped_defs = True
disallow_untyped_defs = True
mypy_path =
st3,
src,
stubs,

[mypy-sublime_lib.vendor.*]
ignore_errors=True

[mypy-sublime_lib._compat.typing_stubs]
disallow_untyped_defs = False
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[project]
name = "sublime_lib"
version = "1.6.0"
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,<=3.9"

[build-system]
requires = ["hatchling>=1.20", "hatch-vcs>=0.4"]
Comment thread
FichteFoll marked this conversation as resolved.
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"flake8>=3.9.2",
"mypy>=0.720",
"pydocstyle>=4.0.0",
"sphinx==4.0.2",
"sphinxcontrib-prettyspecialmethods>=0.1.0",
]

[tool.hatch.build.targets.sdist]
exclude = [
"/.*",
"/stubs",
"*.lock",
]

[tool.coverage.run]
omit = [
"*/tests/*",
]

[tool.coverage.report]
show_missing = true

[tool.pydocstyle]
match_dir = "^(?!_)"
match = "^(?!_).*\\.py"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections.abc import Mapping, Sequence

from .._compat.typing import Callable, Dict, Iterable, TypeVar, Union
from typing import Callable, Dict, Iterable, TypeVar, Union


_V = TypeVar('_V')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from enum import EnumMeta, Enum, Flag
from functools import partial

from .._compat.enum import EnumMeta, Enum, Flag
from .._compat.typing import Any, Callable, Optional
from typing import Any, Callable, Optional


__all__ = ['ExtensibleConstructorMeta', 'construct_with_alternatives', 'construct_union']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
from functools import lru_cache

from .._compat.typing import Callable
from typing import Callable

__all__ = ['get_glob_matcher']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from functools import wraps

from .._compat.typing import Any, Callable, ContextManager, Optional, TypeVar
from typing import Any, Callable, ContextManager, Optional, TypeVar


_Self = TypeVar('_Self')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sublime
import re
from typing import Dict, Union

from .._compat.typing import Dict, Union

YamlScalar = Union[str, bool, None]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import weakref

from .._compat.typing import Callable, Any
from types import MethodType
from typing import Callable, Any


__all__ = ['weak_method']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from uuid import uuid4

from ._compat.typing import Optional, Union
from typing import Optional, Union
from types import TracebackType
from abc import ABCMeta, abstractmethod
from functools import partial
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions st3/sublime_lib/flags.py → src/sublime_lib/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@

import sublime

from ._compat.enum import IntEnum, IntFlag, EnumMeta
from enum import IntEnum, IntFlag, EnumMeta
from inspect import getdoc, cleandoc
from typing import Callable, Optional

import operator
import re

from ._util.enum import ExtensibleConstructorMeta, construct_union, construct_with_alternatives

from ._compat.typing import Callable, Optional


__all__ = [
'DialogResult', 'PointClass', 'FindOption', 'RegionOption',
Expand Down
4 changes: 2 additions & 2 deletions st3/sublime_lib/panel.py → src/sublime_lib/panel.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sublime

from typing import Any

from .view_stream import ViewStream
from .view_utils import set_view_options, validate_view_options
from ._util.guard import define_guard

from ._compat.typing import Any

__all__ = ['Panel', 'OutputPanel']


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sublime

from ._compat.typing import Optional, List, TypeVar, Collection
from typing import Optional, List, TypeVar, Collection

from .flags import RegionOption


Expand Down
Loading
Loading