Skip to content

Commit 4239920

Browse files
committed
Migrate as much configuration as possible to pyproject.toml, migrate pylintrc to toml
1 parent 682fa6b commit 4239920

File tree

15 files changed

+396
-472
lines changed

15 files changed

+396
-472
lines changed

.flake8

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/test-and-publish.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.10"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.10", "pypy-3.11"]
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -27,17 +27,17 @@ jobs:
2727
run: pip install .
2828
- name: Install test dependencies
2929
run: |
30-
pip install --upgrade pytest pytest-asyncio pytest-cov mypy pylint flake8 setuptools
30+
pip install --upgrade .[test,lint]
3131
pip install --upgrade twisted twomemo[xml] oldmemo[xml]
3232
3333
- name: Type-check using mypy
34-
run: mypy --strict --disable-error-code str-bytes-safe omemo/ setup.py examples/ tests/
34+
run: mypy omemo/ examples/ tests/
3535
- name: Lint using pylint
36-
run: pylint omemo/ setup.py examples/ tests/
36+
run: pylint omemo/ examples/ tests/
3737
- name: Format-check using Flake8
38-
run: flake8 omemo/ setup.py examples/ tests/
38+
run: flake8 omemo/ examples/ tests/
3939
- name: Test using pytest
40-
run: pytest --cov=omemo --cov-report term-missing:skip-covered
40+
run: pytest
4141

4242
build:
4343
name: Build source distribution and wheel
@@ -46,8 +46,11 @@ jobs:
4646
steps:
4747
- uses: actions/checkout@v4
4848

49+
- name: Install build
50+
run: pip install build
51+
4952
- name: Build source distribution and wheel
50-
run: python3 setup.py sdist bdist_wheel
53+
run: python -m build --sdist --wheel
5154

5255
- uses: actions/upload-artifact@v4
5356
with:

.readthedocs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ sphinx:
1111

1212
python:
1313
install:
14-
- requirements: docs/requirements.txt
1514
- method: pip
1615
path: .
16+
extra_requirements:
17+
- docs

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1313
- Removed type annotations from enum members in accordance with a new mypy rule
1414
- Simplified the `JSONObject` type now that recursive aliases are properly supported
1515

16+
### Removed
17+
- Removed project.py and simplified version.py as part of the migration towards pyproject.toml
18+
1619
## [1.2.0] - 15th of October, 2024
1720

1821
### Changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ Install the latest release using pip (`pip install OMEMO`) or manually from sour
1818
python-omemo uses [pytest](https://docs.pytest.org/en/latest/) as its testing framework, [mypy](http://mypy-lang.org/) for static type checks and both [pylint](https://pylint.pycqa.org/en/latest/) and [Flake8](https://flake8.pycqa.org/en/latest/) for linting. All tests/checks can be run locally with the following commands:
1919

2020
```sh
21-
$ pip install --upgrade pytest pytest-asyncio pytest-cov mypy pylint flake8
22-
$ pip install --upgrade twisted twomemo[xml] oldmemo[xml]
23-
$ mypy --strict --disable-error-code str-bytes-safe omemo/ setup.py examples/ tests/
24-
$ pylint omemo/ setup.py examples/ tests/
25-
$ flake8 omemo/ setup.py examples/ tests/
26-
$ pytest --cov=omemo --cov-report term-missing:skip-covered
21+
$ pip install --upgrade .[test,lint]
22+
$ mypy omemo/ examples/ tests/
23+
$ pylint omemo/ examples/ tests/
24+
$ flake8 omemo/ examples/ tests/
25+
$ pytest
2726
```
2827

2928
## Getting Started ##
3029

31-
Refer to the documentation on [readthedocs.io](https://py-omemo.readthedocs.io/), or build/view it locally in the `docs/` directory. To build the docs locally, install the requirements listed in `docs/requirements.txt`, e.g. using `pip install -r docs/requirements.txt`, and then run `make html` from within the `docs/` directory. The documentation can then be found in `docs/_build/html/`.
30+
Refer to the documentation on [readthedocs.io](https://py-omemo.readthedocs.io/), or build it locally. Additional requirements to build the docs can be installed using `pip install .[docs]`. With all dependencies installed, run `make html` in the `docs/` directory. The documentation can then be found in `docs/_build/html/`.
3231

3332
The `functionality.md` file contains an overview of supported functionality/use cases, mostly targeted at developers.

docs/conf.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,37 @@
1212
import os
1313
import sys
1414

15-
this_file_path = os.path.dirname(os.path.abspath(__file__))
16-
sys.path.append(os.path.join(this_file_path, "..", "omemo"))
15+
root_dir_path = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
16+
sys.path.append(os.path.join(root_dir_path, "omemo"))
17+
18+
# -- Project information -----------------------------------------------------------------
1719

1820
from version import __version__ as __version
19-
from project import project as __project
2021

21-
# -- Project information -----------------------------------------------------------------
22+
import tomllib
23+
from typing import List
24+
25+
with open(os.path.join(root_dir_path, "pyproject.toml"), "rb") as f:
26+
__pyproject = tomllib.load(f)
27+
28+
project: str = __pyproject["project"]["name"]
29+
author: str = __pyproject["project"]["authors"][0]["name"]
30+
copyright: str = f"2025, {author}"
31+
32+
__classifiers: List[str] = __pyproject["project"]["classifiers"]
2233

23-
project = __project["name"]
24-
author = __project["author"]
25-
copyright = f"{__project['year']}, {__project['author']}"
34+
__tag: str = "unknown"
35+
if "Development Status :: 3 - Alpha" in __classifiers:
36+
__tag = "alpha"
37+
if "Development Status :: 4 - Beta" in __classifiers:
38+
__tag = "beta"
39+
if "Development Status :: 5 - Production/Stable" in __classifiers:
40+
__tag = "stable"
2641

2742
# The short X.Y version
28-
version = __version["short"]
43+
version = __version
2944
# The full version, including alpha/beta/rc tags
30-
release = __version["full"]
45+
release = f"{__version}-{__tag}"
3146

3247
# -- General configuration ---------------------------------------------------------------
3348

docs/requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

omemo/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .version import __version__ as __version__
2-
from .project import project as project
32

43
from .backend import (
54
Backend as Backend,

omemo/project.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

omemo/session_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ async def set_trust(self, bare_jid: str, identity_key: bytes, trust_level_name:
11831183
"""
11841184

11851185
logging.getLogger(SessionManager.LOG_TAG).debug(
1186-
f"Setting trust level for identity key {identity_key} to {trust_level_name}."
1186+
f"Setting trust level for identity key 0x{identity_key.hex()} to {trust_level_name}."
11871187
)
11881188

11891189
await self.__storage.store(
@@ -2220,7 +2220,7 @@ async def handle_key_exchange(
22202220
plain_key_material
22212221
)
22222222

2223-
logging.getLogger(SessionManager.LOG_TAG).debug(f"Message decrypted: {plaintext}")
2223+
logging.getLogger(SessionManager.LOG_TAG).debug(f"Message decrypted: {plaintext!r}")
22242224

22252225
# Persist the session following successful decryption
22262226
await backend.store_session(session)

0 commit comments

Comments
 (0)