From ffc344b5b54c9766c832e383f8d01f6a903b82a2 Mon Sep 17 00:00:00 2001 From: Felix Jung Date: Fri, 9 Feb 2024 14:13:22 +0100 Subject: [PATCH] added blacken-docs for doc code formatting --- .pre-commit-config.yaml | 6 ++++++ doc/extras.rst | 5 ++--- doc/issues.rst | 4 +--- pyproject.toml | 1 + src/ridepy/cli.py | 5 +++++ src/ridepy/extras/io.py | 6 +++--- src/ridepy/extras/simulation_set.py | 13 +++++++++---- src/ridepy/util/dispatchers/__init__.py | 3 +-- 8 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0d93ad1..a56b3f37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,3 +4,9 @@ repos: hooks: - id: black language_version: python3.9 +- repo: https://github.com/adamchainz/blacken-docs + rev: 1.16.0 + hooks: + - id: blacken-docs + additional_dependencies: + - black==24.1.1 diff --git a/doc/extras.rst b/doc/extras.rst index ae58aa4d..b4415c12 100644 --- a/doc/extras.rst +++ b/doc/extras.rst @@ -122,9 +122,8 @@ Later this can e.g. be used as input for the analytics module: .. code-block:: python stops, requests = get_stops_and_requests( - events=read_events_json("events.jsonl"), - space=read_params_json("params.json") - ) + events=read_events_json("events.jsonl"), space=read_params_json("params.json") + ) .. automodule:: ridepy.extras.io :members: diff --git a/doc/issues.rst b/doc/issues.rst index 07ba9bc6..3d534d87 100644 --- a/doc/issues.rst +++ b/doc/issues.rst @@ -10,9 +10,7 @@ If you in fact have run into an unreported issue, please describe clearly which .. code:: markdown ```python - - def my_broken_function(a: int, b:float): + def my_broken_function(a: int, b: float): result = do_stuff() return 42 + result - ``` diff --git a/pyproject.toml b/pyproject.toml index 76c11a64..065e78d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ dev = [ "twine", "build", "auditwheel", + "blacken-docs", ] doc = [ diff --git a/src/ridepy/cli.py b/src/ridepy/cli.py index 0e12e5ea..11996fd6 100644 --- a/src/ridepy/cli.py +++ b/src/ridepy/cli.py @@ -129,11 +129,16 @@ def analyze( respectively. """ + tasks = {"stops", "requests", "vehicle_quantities"} + if compute_system_quantities: + tasks.add("system_quantities") + system_quantities = [] for simulation_id in simulation_ids: _, sys_quant = perform_single_analysis( sim_id=simulation_id, data_dir=output_directory, + tasks_if_existent=tasks, ) system_quantities.append(sys_quant) diff --git a/src/ridepy/extras/io.py b/src/ridepy/extras/io.py index 48520758..733d1eaf 100644 --- a/src/ridepy/extras/io.py +++ b/src/ridepy/extras/io.py @@ -24,7 +24,7 @@ class ParamsJSONEncoder(json.JSONEncoder): .. code-block:: python - >>> json.dumps(params, cls=ParamsJSONEncoder) + json.dumps(params, cls=ParamsJSONEncoder) """ @@ -63,7 +63,7 @@ class ParamsJSONDecoder(json.JSONDecoder): .. code-block:: python - >>> json.loads(params, cls=ParamsJSONDecoder) + json.loads(params, cls=ParamsJSONDecoder) """ @@ -117,7 +117,7 @@ class EventsJSONEncoder(json.JSONEncoder): .. code-block:: python - >>> json.dumps(events, cls=EventsJSONEncoder) + json.dumps(events, cls=EventsJSONEncoder) """ diff --git a/src/ridepy/extras/simulation_set.py b/src/ridepy/extras/simulation_set.py index a68f1d92..18eddcc9 100644 --- a/src/ridepy/extras/simulation_set.py +++ b/src/ridepy/extras/simulation_set.py @@ -425,10 +425,15 @@ def _two_level_dict_update( .. code-block:: python - >>> SimulationSet._two_level_dict_update( - ... {"a": {"b": 5, 6: 8}}, {"a": {6: "fooo", 8: "baaar"}, "baz": {"6": 6}} - ... ) - {'a': {'b': 5, 6: 'fooo', 8: 'baaar'}, 'baz': {'6': 6}} + SimulationSet._two_level_dict_update( + {"a": {"b": 5, 6: 8}}, {"a": {6: "fooo", 8: "baaar"}, "baz": {"6": 6}} + ) + + yields + + .. code-block:: python + + {"a": {"b": 5, 6: "fooo", 8: "baaar"}, "baz": {"6": 6}} Parameters diff --git a/src/ridepy/util/dispatchers/__init__.py b/src/ridepy/util/dispatchers/__init__.py index ec1b4293..9f3a1097 100644 --- a/src/ridepy/util/dispatchers/__init__.py +++ b/src/ridepy/util/dispatchers/__init__.py @@ -51,8 +51,7 @@ def MyFancyDispatcher( stoplist: Stoplist, space: TransportSpace, seat_capacity: int, - ) -> SingleVehicleSolution: - ... + ) -> SingleVehicleSolution: ... """