From 6354e1bfeb394ad356a007354f1546346e685c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20C=C3=A1rdenas=20Rodr=C3=ADguez?= Date: Mon, 27 May 2024 21:52:46 +0200 Subject: [PATCH] setting up CI --- .github/workflows/test.yml | 14 ++++++-------- xdevs/__init__.py | 1 + xdevs/models.py | 3 ++- xdevs/plugins/input_handlers/bad_dependencies.py | 4 +++- xdevs/plugins/input_handlers/csv.py | 1 + xdevs/plugins/input_handlers/function.py | 1 + xdevs/plugins/input_handlers/mqtt.py | 1 + xdevs/plugins/output_handlers/bad_dependencies.py | 4 +++- xdevs/plugins/output_handlers/csv.py | 1 + xdevs/plugins/output_handlers/mqtt.py | 1 + xdevs/plugins/output_handlers/tcp.py | 1 + xdevs/plugins/transducers/bad_dependencies.py | 4 +++- xdevs/plugins/wrappers/bad_dependencies.py | 4 +++- xdevs/plugins/wrappers/pypdevs.py | 2 ++ xdevs/sim.py | 1 - 15 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82c66a3..42ddcae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,24 +1,19 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application - +name: Build and test on: push: branches: [ "main", "dev-json" ] pull_request: branches: [ "main" ] merge_group: - -permissions: - contents: read - jobs: build: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Setup Python @@ -28,8 +23,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install --upgrade importlib-metadata pip install pytest - python -m install + - name: install xDEVS + run: | + python -m pip install . - name: Test with pytest run: | pytest diff --git a/xdevs/__init__.py b/xdevs/__init__.py index baf4dd9..04cb2d7 100644 --- a/xdevs/__init__.py +++ b/xdevs/__init__.py @@ -1,3 +1,4 @@ +from __future__ import annotations import functools import logging import math diff --git a/xdevs/models.py b/xdevs/models.py index 692cbaa..b859e56 100644 --- a/xdevs/models.py +++ b/xdevs/models.py @@ -29,7 +29,8 @@ def __len__(self) -> int: return sum((len(port) for port in self._bag), len(self._values)) def __str__(self) -> str: - return f'{self.name}<{self.p_type.__name__ if self.p_type is not None else 'None'}>' + p_type = self.p_type.__name__ if self.p_type is not None else 'None' + return f'{self.name}<{p_type}>' def __repr__(self) -> str: return str(self) diff --git a/xdevs/plugins/input_handlers/bad_dependencies.py b/xdevs/plugins/input_handlers/bad_dependencies.py index 6c864c3..8c3c8f2 100644 --- a/xdevs/plugins/input_handlers/bad_dependencies.py +++ b/xdevs/plugins/input_handlers/bad_dependencies.py @@ -1,3 +1,4 @@ +from __future__ import annotations from abc import ABC from xdevs.abc.handler import InputHandler @@ -9,7 +10,8 @@ def __init__(self, **kwargs): :param str handler_type: transducer type. """ super().__init__(**kwargs) - raise ImportError(f'{kwargs.get('handler_type')} input handler specific dependencies are not imported') + handler_type = kwargs['handler_type'] + raise ImportError(f'{handler_type} input handler specific dependencies are not imported') def run(self): pass diff --git a/xdevs/plugins/input_handlers/csv.py b/xdevs/plugins/input_handlers/csv.py index 581614f..b69e24e 100644 --- a/xdevs/plugins/input_handlers/csv.py +++ b/xdevs/plugins/input_handlers/csv.py @@ -1,3 +1,4 @@ +from __future__ import annotations import csv import sys import time diff --git a/xdevs/plugins/input_handlers/function.py b/xdevs/plugins/input_handlers/function.py index 880b0d2..ac09420 100644 --- a/xdevs/plugins/input_handlers/function.py +++ b/xdevs/plugins/input_handlers/function.py @@ -1,3 +1,4 @@ +from __future__ import annotations from xdevs.abc.handler import InputHandler diff --git a/xdevs/plugins/input_handlers/mqtt.py b/xdevs/plugins/input_handlers/mqtt.py index 0cb0e2e..5917942 100644 --- a/xdevs/plugins/input_handlers/mqtt.py +++ b/xdevs/plugins/input_handlers/mqtt.py @@ -1,3 +1,4 @@ +from __future__ import annotations import queue import threading diff --git a/xdevs/plugins/output_handlers/bad_dependencies.py b/xdevs/plugins/output_handlers/bad_dependencies.py index b1fe605..201313d 100644 --- a/xdevs/plugins/output_handlers/bad_dependencies.py +++ b/xdevs/plugins/output_handlers/bad_dependencies.py @@ -1,3 +1,4 @@ +from __future__ import annotations from abc import ABC from xdevs.abc.handler import OutputHandler @@ -9,7 +10,8 @@ def __init__(self, **kwargs): :param str handler_type: transducer type. """ super().__init__(**kwargs) - raise ImportError(f'{kwargs['handler_type']} input handler specific dependencies are not imported') + handler_type = kwargs['handler_type'] + raise ImportError(f'{handler_type} input handler specific dependencies are not imported') def run(self): pass diff --git a/xdevs/plugins/output_handlers/csv.py b/xdevs/plugins/output_handlers/csv.py index 701b0ac..b77d365 100644 --- a/xdevs/plugins/output_handlers/csv.py +++ b/xdevs/plugins/output_handlers/csv.py @@ -1,3 +1,4 @@ +from __future__ import annotations import csv import time from xdevs.abc.handler import OutputHandler diff --git a/xdevs/plugins/output_handlers/mqtt.py b/xdevs/plugins/output_handlers/mqtt.py index a6d6040..70e115a 100644 --- a/xdevs/plugins/output_handlers/mqtt.py +++ b/xdevs/plugins/output_handlers/mqtt.py @@ -1,3 +1,4 @@ +from __future__ import annotations from typing import Callable, Any try: diff --git a/xdevs/plugins/output_handlers/tcp.py b/xdevs/plugins/output_handlers/tcp.py index 1b78f66..a26c019 100644 --- a/xdevs/plugins/output_handlers/tcp.py +++ b/xdevs/plugins/output_handlers/tcp.py @@ -1,3 +1,4 @@ +from __future__ import annotations import time from typing import Any, Callable diff --git a/xdevs/plugins/transducers/bad_dependencies.py b/xdevs/plugins/transducers/bad_dependencies.py index d03cbf2..432c757 100644 --- a/xdevs/plugins/transducers/bad_dependencies.py +++ b/xdevs/plugins/transducers/bad_dependencies.py @@ -1,3 +1,4 @@ +from __future__ import annotations from abc import ABC from xdevs.abc.transducer import Transducer @@ -9,7 +10,8 @@ def __init__(self, **kwargs): :param str transducer_type: transducer type. """ super().__init__(**kwargs) - raise ImportError(f'{kwargs.get('transducer_type')} transducer specific dependencies are not imported') + transducer_type = kwargs['transducer_type'] + raise ImportError(f'{transducer_type} transducer specific dependencies are not imported') def create_known_data_types_map(self): pass diff --git a/xdevs/plugins/wrappers/bad_dependencies.py b/xdevs/plugins/wrappers/bad_dependencies.py index d37c58e..116ad49 100644 --- a/xdevs/plugins/wrappers/bad_dependencies.py +++ b/xdevs/plugins/wrappers/bad_dependencies.py @@ -1,3 +1,4 @@ +from __future__ import annotations from abc import ABC from xdevs.models import Atomic @@ -9,7 +10,8 @@ def __init__(self, **kwargs): :param str wrapper_type: wrapper type. """ super().__init__(**kwargs) - raise ImportError(f'{kwargs['wrapper_type']} wrapper specific dependencies are not installed') + wrapper_type = kwargs['wrapper_type'] + raise ImportError(f'{wrapper_type} wrapper specific dependencies are not installed') def deltint(self): pass diff --git a/xdevs/plugins/wrappers/pypdevs.py b/xdevs/plugins/wrappers/pypdevs.py index 01eb3d2..789577f 100644 --- a/xdevs/plugins/wrappers/pypdevs.py +++ b/xdevs/plugins/wrappers/pypdevs.py @@ -1,3 +1,5 @@ +from __future__ import annotations + try: from pypdevs.DEVS import AtomicDEVS from pypdevs.minimal import AtomicDEVS as AtomicDEVSMin diff --git a/xdevs/sim.py b/xdevs/sim.py index 3e5fa77..36c7115 100644 --- a/xdevs/sim.py +++ b/xdevs/sim.py @@ -4,7 +4,6 @@ import itertools import pickle import logging -import warnings from abc import ABC, abstractmethod from collections import defaultdict