Skip to content

Commit

Permalink
Revert "Adding support for file-based reads and externalized type dep…
Browse files Browse the repository at this point in the history
…endencies (#102)"

This reverts commit 31df90d.
  • Loading branch information
thirtytwobits committed May 27, 2024
1 parent 31df90d commit 98453a4
Show file tree
Hide file tree
Showing 20 changed files with 292 additions and 1,546 deletions.
24 changes: 0 additions & 24 deletions .devcontainer/devcontainer.json

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
python: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
include:
- os: windows-2019
python: '3.10'
Expand Down Expand Up @@ -60,6 +60,7 @@ jobs:
echo "${{ runner.os }} not supported"
exit 1
fi
python -c "import pydsdl; pydsdl.read_namespace('.dsdl-test/uavcan', [])"
shell: bash

pydsdl-release:
Expand Down
7 changes: 0 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- graphviz

sphinx:
configuration: docs/conf.py
fail_on_warning: true
Expand Down
71 changes: 0 additions & 71 deletions conftest.py

This file was deleted.

5 changes: 2 additions & 3 deletions docs/pages/pydsdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ You can find a practical usage example in the Nunavut code generation library th
:local:


The main functions
++++++++++++++++++
The main function
+++++++++++++++++

.. autofunction:: pydsdl.read_namespace
.. autofunction:: pydsdl.read_files


Type model
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx >= 5.0
sphinx_rtd_theme >= 1.0.0
sphinx == 4.4.0
sphinx_rtd_theme == 1.0.0
sphinx-computron >= 0.2, < 2.0
63 changes: 29 additions & 34 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import nox


PYTHONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
PYTHONS = ["3.8", "3.9", "3.10", "3.11"]
"""The newest supported Python shall be listed LAST."""

nox.options.error_on_external_run = True
Expand All @@ -33,6 +33,7 @@ def clean(session):
"*.log",
"*.tmp",
".nox",
".dsdl-test",
]
for w in wildcards:
for f in Path.cwd().glob(w):
Expand All @@ -48,9 +49,9 @@ def test(session):
session.log("Using the newest supported Python: %s", is_latest_python(session))
session.install("-e", ".")
session.install(
"pytest ~= 8.1",
"pytest-randomly ~= 3.15",
"coverage ~= 7.5",
"pytest ~= 7.3",
"pytest-randomly ~= 3.12",
"coverage ~= 7.2",
)
session.run("coverage", "run", "-m", "pytest")
session.run("coverage", "report", "--fail-under=95")
Expand All @@ -60,7 +61,7 @@ def test(session):
session.log(f"OPEN IN WEB BROWSER: file://{report_file}")


@nox.session(python=["3.8"])
@nox.session(python=["3.7"])
def test_eol(session):
"""This is a minimal test session for those old Pythons that have EOLed."""
session.install("-e", ".")
Expand All @@ -82,33 +83,30 @@ def pristine(session):

@nox.session(python=PYTHONS, reuse_venv=True)
def lint(session):
if is_oldest_python(session):
# we run mypy and pylint only on the oldest Python version to ensure maximum compatibility
session.install(
"mypy ~= 1.10",
"types-parsimonious",
"pylint ~= 3.2",
)
session.run(
"mypy",
"--strict",
f"--config-file={ROOT_DIR / 'setup.cfg'}",
"pydsdl",
env={
"MYPYPATH": str(THIRD_PARTY_DIR),
},
)
session.run(
"pylint",
str(ROOT_DIR / "pydsdl"),
env={
"PYTHONPATH": str(THIRD_PARTY_DIR),
},
)
session.log("Using the newest supported Python: %s", is_latest_python(session))
session.install(
"mypy ~= 1.2.0",
"pylint ~= 2.17.2",
)
session.run(
"mypy",
"--strict",
f"--config-file={ROOT_DIR / 'setup.cfg'}",
"pydsdl",
env={
"MYPYPATH": str(THIRD_PARTY_DIR),
},
)
session.run(
"pylint",
str(ROOT_DIR / "pydsdl"),
env={
"PYTHONPATH": str(THIRD_PARTY_DIR),
},
)
if is_latest_python(session):
# we run black only on the newest Python version to ensure that the code is formatted with the latest version
session.install("black ~= 24.4")
session.run("black", "--check", f"{ROOT_DIR / 'pydsdl'}")
session.install("black ~= 23.3")
session.run("black", "--check", ".")


@nox.session(reuse_venv=True)
Expand All @@ -123,6 +121,3 @@ def docs(session):

def is_latest_python(session) -> bool:
return PYTHONS[-1] in session.run("python", "-V", silent=True)

def is_oldest_python(session) -> bool:
return PYTHONS[0] in session.run("python", "-V", silent=True)
5 changes: 2 additions & 3 deletions pydsdl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys as _sys
from pathlib import Path as _Path

__version__ = "1.21.0"
__version__ = "1.20.1"
__version_info__ = tuple(map(int, __version__.split(".")[:3]))
__license__ = "MIT"
__author__ = "OpenCyphal"
Expand All @@ -25,9 +25,8 @@
_sys.path = [str(_Path(__file__).parent / "third_party")] + _sys.path

# Never import anything that is not available here - API stability guarantees are only provided for the exposed items.
from ._dsdl import PrintOutputHandler as PrintOutputHandler
from ._namespace import read_namespace as read_namespace
from ._namespace import read_files as read_files
from ._namespace import PrintOutputHandler as PrintOutputHandler

# Error model.
from ._error import FrontendError as FrontendError
Expand Down
20 changes: 12 additions & 8 deletions pydsdl/_bit_length_set/_symbolic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This software is distributed under the terms of the MIT License.
# Author: Pavel Kirienko <[email protected]>

import typing
import random
import itertools
from ._symbolic import NullaryOperator, validate_numerically
Expand Down Expand Up @@ -139,7 +140,7 @@ def _unittest_repetition() -> None:
)
assert op.min == 7 * 3
assert op.max == 17 * 3
assert set(op.expand()) == set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 3)))
assert set(op.expand()) == set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 3))) # type: ignore
assert set(op.expand()) == {21, 25, 29, 31, 33, 35, 39, 41, 45, 51}
assert set(op.modulo(7)) == {0, 1, 2, 3, 4, 5, 6}
assert set(op.modulo(8)) == {1, 3, 5, 7}
Expand All @@ -148,15 +149,15 @@ def _unittest_repetition() -> None:
for _ in range(1):
child = NullaryOperator(random.randint(0, 100) for _ in range(random.randint(1, 10)))
k = random.randint(0, 10)
ref = set(map(sum, itertools.combinations_with_replacement(child.expand(), k)))
ref = set(map(sum, itertools.combinations_with_replacement(child.expand(), k))) # type: ignore
op = RepetitionOperator(child, k)
assert set(op.expand()) == ref

assert op.min == min(child.expand()) * k
assert op.max == max(child.expand()) * k

div = random.randint(1, 64)
assert set(op.modulo(div)) == {x % div for x in ref}
assert set(op.modulo(div)) == {typing.cast(int, x) % div for x in ref}

validate_numerically(op)

Expand All @@ -172,9 +173,9 @@ def _unittest_range_repetition() -> None:
assert op.max == 17 * 3
assert set(op.expand()) == (
{0}
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 1)))
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 2)))
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 3)))
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 1))) # type: ignore
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 2))) # type: ignore
| set(map(sum, itertools.combinations_with_replacement([7, 11, 17], 3))) # type: ignore
)
assert set(op.expand()) == {0, 7, 11, 14, 17, 18, 21, 22, 24, 25, 28, 29, 31, 33, 34, 35, 39, 41, 45, 51}
assert set(op.modulo(7)) == {0, 1, 2, 3, 4, 5, 6}
Expand All @@ -196,7 +197,10 @@ def _unittest_range_repetition() -> None:
k_max = random.randint(0, 10)
ref = set(
itertools.chain(
*(map(sum, itertools.combinations_with_replacement(child.expand(), k)) for k in range(k_max + 1))
*(
map(sum, itertools.combinations_with_replacement(child.expand(), k)) # type: ignore
for k in range(k_max + 1)
)
)
)
op = RangeRepetitionOperator(child, k_max)
Expand All @@ -206,7 +210,7 @@ def _unittest_range_repetition() -> None:
assert op.max == max(child.expand()) * k_max

div = random.randint(1, 64)
assert set(op.modulo(div)) == {x % div for x in ref}
assert set(op.modulo(div)) == {typing.cast(int, x) % div for x in ref}

validate_numerically(op)

Expand Down
Loading

0 comments on commit 98453a4

Please sign in to comment.