Skip to content

Commit c917398

Browse files
committed
general: set min python version to 3.9 and cleanup CI files
1 parent ed12951 commit c917398

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+189
-166
lines changed

.ci/run

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ if ! command -v sudo; then
1111
}
1212
fi
1313

14+
# --parallel-live to show outputs while it's running
15+
tox_cmd='run-parallel --parallel-live'
1416
if [ -n "${CI-}" ]; then
1517
# install OS specific stuff here
1618
case "$OSTYPE" in
@@ -21,7 +23,8 @@ if [ -n "${CI-}" ]; then
2123
;;
2224
cygwin* | msys* | win*)
2325
# windows
24-
:
26+
# ugh. parallel stuff seems super flaky under windows, some random failures, "file used by other process" and crap like that
27+
tox_cmd='run'
2528
;;
2629
*)
2730
# must be linux?
@@ -40,5 +43,9 @@ if ! command -v python3 &> /dev/null; then
4043
PY_BIN="python"
4144
fi
4245

43-
"$PY_BIN" -m pip install --user tox
44-
"$PY_BIN" -m tox --parallel --parallel-live "$@"
46+
47+
# TODO hmm for some reason installing uv with pip and then running
48+
# "$PY_BIN" -m uv tool fails with missing setuptools error??
49+
# just uvx directly works, but it's not present in PATH...
50+
"$PY_BIN" -m pip install --user pipx
51+
"$PY_BIN" -m pipx run uv tool run --with=tox-uv tox $tox_cmd "$@"

.github/workflows/main.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
platform: [ubuntu-latest, macos-latest] # todo enable windows-latest later -- need to fix a couple of tests first
28-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
28+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2929
# vvv just an example of excluding stuff from matrix
3030
# exclude: [{platform: macos-latest, python-version: '3.6'}]
3131

@@ -56,8 +56,15 @@ jobs:
5656
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
5757
uses: actions/upload-artifact@v4
5858
with:
59-
name: .coverage.mypy_${{ matrix.platform }}_${{ matrix.python-version }}
60-
path: .coverage.mypy/
59+
include-hidden-files: true
60+
name: .coverage.mypy-core_${{ matrix.platform }}_${{ matrix.python-version }}
61+
path: .coverage.mypy-core/
62+
- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
63+
uses: actions/upload-artifact@v4
64+
with:
65+
include-hidden-files: true
66+
name: .coverage.mypy-misc_${{ matrix.platform }}_${{ matrix.python-version }}
67+
path: .coverage.mypy-misc/
6168

6269

6370
pypi:
@@ -70,7 +77,7 @@ jobs:
7077

7178
- uses: actions/setup-python@v5
7279
with:
73-
python-version: '3.8'
80+
python-version: '3.10'
7481

7582
- uses: actions/checkout@v4
7683
with:

mypy.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
[mypy]
2-
namespace_packages = True
32
pretty = True
43
show_error_context = True
5-
show_error_codes = True
64
show_column_numbers = True
75
show_error_end = True
6+
warn_redundant_casts = True
87
warn_unused_ignores = True
98
check_untyped_defs = True
10-
enable_error_code = possibly-undefined
119
strict_equality = True
10+
enable_error_code = possibly-undefined
1211

1312
# an example of suppressing
1413
# [mypy-my.config.repos.pdfannots.pdfannots]

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencies = [
66
"appdirs" , # to keep state files
77
"atomicwrites", # to safely append data to a file
88
]
9+
requires-python = ">= 3.9"
910

1011
## these need to be set if you're planning to upload to pypi
1112
description = "Converts data into org-mode"

ruff.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
target-version = "py38" # NOTE: inferred from pyproject.toml if present
1+
target-version = "py39" # NOTE: inferred from pyproject.toml if present
22

33
lint.extend-select = [
44
"F", # flakes rules -- default, but extend just in case
@@ -9,7 +9,7 @@ lint.extend-select = [
99
"C4", # flake8-comprehensions -- unnecessary list/map/dict calls
1010
"COM", # trailing commas
1111
"EXE", # various checks wrt executable files
12-
# "I", # sort imports
12+
"I", # sort imports
1313
"ICN", # various import conventions
1414
"FBT", # detect use of boolean arguments
1515
"FURB", # various rules
@@ -30,6 +30,7 @@ lint.extend-select = [
3030
"PTH", # pathlib migration
3131
"ARG", # unused argument checks
3232
"A", # builtin shadowing
33+
"G", # logging stuff
3334
# "EM", # TODO hmm could be helpful to prevent duplicate err msg in traceback.. but kinda annoying
3435

3536
# "ALL", # uncomment this to check for new rules!
@@ -63,10 +64,9 @@ lint.ignore = [
6364
"E402", # Module level import not at top of file
6465

6566
### maybe consider these soon
66-
# sometimes it's useful to give a variable a name even if we don't use it as a documentation
67-
# on the other hand, often is a sign of error
67+
# sometimes it's useful to give a variable a name even if we don't use it as a documentation
68+
# on the other hand, often is a sign of error
6869
"F841", # Local variable `count` is assigned to but never used
69-
"F401", # imported but unused
7070
###
7171

7272
"RUF100", # unused noqa -- handle later
@@ -127,6 +127,8 @@ lint.ignore = [
127127

128128
"TID252", # Prefer absolute imports over relative imports from parent modules
129129

130+
"UP038", # suggests using | (union) in isisntance checks.. but it results in slower code
131+
130132
## too annoying
131133
"T20", # just complains about prints and pprints
132134
"Q", # flake quotes, too annoying

src/orger/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from typing import TYPE_CHECKING
22

3-
from .org_view import Mirror, OrgWithKey, Queue, StaticView
3+
from .org_view import Mirror, OrgWithKey, Queue
4+
5+
__all__ = [
6+
'Mirror',
7+
'OrgWithKey',
8+
'Queue',
9+
]
10+
411

512
if not TYPE_CHECKING:
613
# TODO deprecate properly?
714
InteractiveView = Queue
15+
StaticView = Mirror

src/orger/atomic_append.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
from __future__ import annotations
2+
13
import logging
24
from os.path import lexists
35
from pathlib import Path
4-
from typing import Union
56

6-
PathIsh = Union[str, Path]
77

88
def atomic_append_raw(
9-
path: PathIsh,
10-
data: str,
9+
path: Path | str,
10+
data: str,
1111
) -> None:
1212
path = Path(path)
1313
# https://stackoverflow.com/a/13232181
@@ -25,13 +25,13 @@ def assert_not_edited(path: Path) -> None:
2525
emacs = '.#' + path.name
2626
for x in [vim, emacs]:
2727
lf = path.parent / x
28-
if lexists(lf): # lexist is necessary because emacs uses symlink for lock file
28+
if lexists(lf): # lexist is necessary because emacs uses symlink for lock file
2929
raise RuntimeError(f'File is being edited: {lf}')
3030

3131

3232
def atomic_append_check(
33-
path: PathIsh,
34-
data: str,
33+
path: Path | str,
34+
data: str,
3535
) -> None:
3636
"""
3737
This is editor (emacs/vim)-aware and checks for existence of swap file first.
@@ -56,8 +56,9 @@ def test_atomic_append_check(tmp_path: Path) -> None:
5656
of.touch()
5757

5858
from contextlib import contextmanager
59-
from subprocess import PIPE, Popen, check_call
59+
from subprocess import PIPE, Popen
6060
from time import sleep
61+
6162
@contextmanager
6263
def tmp_popen(*args, **kwargs):
6364
with Popen(*args, **kwargs) as p:
@@ -70,7 +71,7 @@ def tmp_popen(*args, **kwargs):
7071
atomic_append_check(of, 'data2')
7172
assert of.read_text() == 'data1data2'
7273

73-
with tmp_popen(['vi', '-c', 'startinsert', str(of)], stdin=PIPE, stdout=PIPE, stderr=PIPE) as p: # enter insert mode
74+
with tmp_popen(['vi', '-c', 'startinsert', str(of)], stdin=PIPE, stdout=PIPE, stderr=PIPE) as p: # enter insert mode
7475
for _attempt in range(10):
7576
# ugh, needs long pause for some reason
7677
sleep(1)

src/orger/common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class settings:
1616

1717

1818
_timezones = set() # type: ignore
19+
20+
1921
def dt_heading(dt: datetime | None, heading: str) -> str:
2022
"""
2123
Helper to inline datetime in heading
@@ -27,7 +29,9 @@ def dt_heading(dt: datetime | None, heading: str) -> str:
2729
tz = dt.tzinfo
2830
# todo come up with a better way of reporting this..
2931
if tz not in _timezones and len(_timezones) > 0:
30-
warnings.warn(f"Seems that a mixture of timezones is used. Org-mode doesn't support timezones, so this might end up confusing: {_timezones} {tz} {heading}")
32+
warnings.warn(
33+
f"Seems that a mixture of timezones is used. Org-mode doesn't support timezones, so this might end up confusing: {_timezones} {tz} {heading}"
34+
)
3135
_timezones.add(tz)
3236

3337
return timestamp_with_style(dt=dt, style=settings.DEFAULT_TIMESTAMP_STYLE) + ' ' + heading
@@ -57,9 +61,10 @@ def todo(dt: datetime, **kwargs):
5761

5862
def orger_user_dir() -> Path:
5963
import appdirs # type: ignore[import-untyped]
64+
6065
return Path(appdirs.user_config_dir('orger'))
6166

6267

6368
if not TYPE_CHECKING:
6469
# legacy imports for bwd compatibility
65-
from .logging_helper import LazyLogger, setup_logger
70+
from .logging_helper import LazyLogger, setup_logger # noqa: F401

src/orger/inorganic.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
from __future__ import annotations
22

3-
import logging
43
import os
54
import re
65
import textwrap
76
import warnings
8-
from collections import OrderedDict
7+
from collections.abc import Mapping, Sequence
98
from dataclasses import dataclass
109
from datetime import date, datetime
1110
from enum import Enum
1211
from pathlib import Path
1312
from typing import (
14-
TYPE_CHECKING,
15-
Any,
1613
Callable,
17-
Mapping,
18-
Sequence,
1914
TypeVar,
2015
Union,
2116
)

src/orger/modules/auto.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/usr/bin/env python3
22
from __future__ import annotations
33

4-
from orger import Mirror
5-
from orger.inorganic import node, link, Quoted
6-
from orger.common import dt_heading, error
7-
4+
import string
5+
from collections.abc import Iterator
86
from datetime import datetime
9-
from typing import Iterator, Any
107
from pprint import pformat
11-
import string
8+
from typing import Any
129

1310
from more_itertools import bucket
14-
1511
from my.core.types import asdict
1612

13+
from orger import Mirror
14+
from orger.common import dt_heading, error
15+
from orger.inorganic import Quoted, node
16+
1717

1818
def pp_item(i, **kwargs) -> str:
1919
# annoying, pprint doesn't have dataclass support till 3.10 https://bugs.python.org/issue43080

0 commit comments

Comments
 (0)