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
37 changes: 15 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
test:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install package
run: pip install .

- name: Install black
run: pip install black

- name: Check code formatting with black
run: black --check stubs/

- name: Type check with mypy
run: mypy stubs/
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Check code formatting with ruff
run: uv run ruff check

- name: Type check with mypy
run: uv run mypy
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish

on:
release:
types: [ published ]
workflow_dispatch:

jobs:

publish:
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Build
run: uv build

- name: Publish
if: github.event_name == 'release'
run: uv publish --trusted-publishing always
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 LICENSE.txt → LICENSE
100755 → 100644
File renamed without changes.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include pythonista_stubs/*.pyi
Comment thread
o-murphy marked this conversation as resolved.
Comment thread
o-murphy marked this conversation as resolved.
Comment thread
o-murphy marked this conversation as resolved.
include VERSION
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.4.0
Comment thread
o-murphy marked this conversation as resolved.
5 changes: 0 additions & 5 deletions mypy.ini

This file was deleted.

76 changes: 76 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[build-system]
requires = ["setuptools>=80.1.0"]
build-backend = "setuptools.build_meta"

[project]
name = "pythonista-stubs"
authors = [
{ name = "Harold Martin" },
{ name = "Dmytro Yaroshenko" }
]
description = "A collection of Pythonista stub files"
readme = "README.md"
requires-python = ">=3.10"
Comment thread
o-murphy marked this conversation as resolved.
dependencies = [
"types-pillow>=10.2.0.20240822",
"typing-extensions>=4.14.1",
]
license = { file = "LICENSE" }
keywords = ["pythonista", "stubs", "ios", "ide"]
classifiers = [
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
]
dynamic = ['version']

[project.urls]
"Homepage" = "https://github.com/hbmartin/pythonista-stubs"
"Bug Reports" = "https://github.com/hbmartin/pythonista-stubs/issues"
"Source" = "https://github.com/hbmartin/pythonista-stubs"

[project.optional-dependencies]
dev = [
"mypy>=1.17.1",
"ruff>=0.12.8",
]

[tool.setuptools.package-dir]
"pythonista_stubs" = "stubs"

[tool.setuptools.packages.find]
where = ["stubs"]
include = [
"pythonista_stubs*",
]

[tool.setuptools.package-data]
"*" = ["**/*"] # to include root-places .pyi stubs

[tool.setuptools.dynamic]
version = { file = "VERSION" }

[dependency-groups]
dev = [
"mypy>=1.17.1", # as a dev dependency, Pythonista does not support mypy
"ruff>=0.12.8",
]
Comment thread
o-murphy marked this conversation as resolved.
Comment thread
o-murphy marked this conversation as resolved.

[tool.mypy]
packages = ["stubs"]
ignore_missing_imports = true

[tool.ruff]
include = [
"pyproject.toml",
"stubs/**/*.py",
"stubs/**/*.pyi",
]
38 changes: 1 addition & 37 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
from setuptools import setup
from os import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()

packages = ["appex", "clipboard", "console", "editor", "reminders", "sound", "speech", "ui"]
packages_stubs = [p + "-stubs" for p in packages]
package_dir = {p + "-stubs": path.join("stubs", p) for p in packages}
package_data = {ps: ["__init__.pyi"] for ps in packages_stubs}

setup(
name="pythonista-stubs",
version="0.0.3",
description="A collection of Pythonista stub files",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/hbmartin/pythonista-stubs",
package_dir=package_dir,
packages=packages_stubs,
package_data=package_data,
install_requires=["typing_extensions", "mypy", "Pillow"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved :: Apache Software License",
"Operating System :: iOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
],
license="Apache License 2.0",
keywords="pythonista stubs ios ide",
project_urls={"Bug Reports": "https://github.com/hbmartin/pythonista-stubs/issues"},
)
setup()
103 changes: 103 additions & 0 deletions stubs/_cb.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Created on July, 07 2025 by o-murphy <https://github.com/o-murphy>
"""
pythonista `_cb` module type annotations
according to [pythonista.cb docs](https://omz-software.com/pythonista/docs/ios/cb.html)
and references to pythonista built-in `_cb` module help
>>> import _cb
>>> help(_cb)
"""

from typing import Optional, List

__all__ = (
"CM_STATE_UNKNOWN",
"CM_STATE_RESETTING",
"CM_STATE_UNSUPPORTED",
"CM_STATE_UNAUTHORIZED",
"CM_STATE_POWERED_OFF",
"CM_STATE_POWERED_ON",
"CH_PROP_BROADCAST",
"CH_PROP_READ",
"CH_PROP_WRITE_WITHOUT_RESPONSE",
"CH_PROP_WRITE",
"CH_PROP_NOTIFY",
"CH_PROP_INDICATE",
"CH_PROP_AUTHENTICATED_SIGNED_WRITES",
"CH_PROP_EXTENDED_PROPERTIES",
"CH_PROP_NOTIFY_ENCRYPTION_REQUIRED",
"CH_PROP_INDICATE_ENCRYPTION_REQUIRED",
"Characteristic",
"Service",
"Peripheral",
"CentralManager",
)

CM_STATE_UNKNOWN: int = 0
CM_STATE_RESETTING: int = 1
CM_STATE_UNSUPPORTED: int = 2
CM_STATE_UNAUTHORIZED: int = 3
CM_STATE_POWERED_OFF: int = 4
CM_STATE_POWERED_ON: int = 5

CH_PROP_BROADCAST: int = 1
CH_PROP_READ: int = 2
CH_PROP_WRITE_WITHOUT_RESPONSE: int = 4
CH_PROP_WRITE: int = 8
CH_PROP_NOTIFY: int = 16
CH_PROP_INDICATE: int = 32
CH_PROP_AUTHENTICATED_SIGNED_WRITES: int = 64
CH_PROP_EXTENDED_PROPERTIES: int = 128
CH_PROP_NOTIFY_ENCRYPTION_REQUIRED: int = 256
CH_PROP_INDICATE_ENCRYPTION_REQUIRED: int = 512

class Characteristic:
properties: int
value: Optional[bytes]
uuid: str # hex
notifying: bool

class Service:
characteristics: List[Characteristic]
primary: bool
uuid: str # hex

class Peripheral:
manufacturer_data: bytes
name: Optional[str]
uuid: str # hex
state: int
services: List[Service]

def discover_services(self) -> None: ...
def discover_characteristics(self, service: Service) -> None: ...
def set_notify_value(
self, characteristic: Characteristic, flag: bool = True
) -> None: ...
def write_characteristic_value(
self, characteristic, data, with_response
) -> None: ...
def read_characteristic_value(self, characteristic: Characteristic) -> None: ...

class CentralManager:
state: int

def __init__(self) -> None: ...
def scan_for_peripherals(self) -> None: ...
def stop_scan(self) -> None: ...
def connect_peripheral(self, p: Peripheral) -> None: ...
def cancel_peripheral_connection(self, p: Peripheral) -> None: ...
def did_discover_peripheral(self, p: Peripheral) -> None: ...
def did_connect_peripheral(self, p: Peripheral) -> None: ...
def did_fail_to_connect_peripheral(
self, p: Peripheral, error: Optional[str]
) -> None: ...
def did_disconnect_peripheral(
self, p: Peripheral, error: Optional[str]
) -> None: ...
def did_discover_services(self, p: Peripheral, error: Optional[str]) -> None: ...
def did_discover_characteristics(
self, s: Service, error: Optional[str]
) -> None: ...
def did_write_value(self, c: Characteristic, error: Optional[str]) -> None: ...
def did_update_value(self, c: Characteristic, error: Optional[str]) -> None: ...
def did_update_state(self) -> None: ...
16 changes: 0 additions & 16 deletions stubs/appex/__init__.pyi

This file was deleted.

9 changes: 0 additions & 9 deletions stubs/clipboard/__init__.pyi

This file was deleted.

Loading