Skip to content

Commit

Permalink
chore!: Drop support for Python 3.8
Browse files Browse the repository at this point in the history
* Use type-hinting provided out of the box in 3.9.
* Use new dictionary update syntax.
* Update the docs and CI accordingly.
  • Loading branch information
jmgate committed Dec 2, 2024
1 parent 2b7c72b commit a9c8005
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
steps:

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/staged-script/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/staged-script/master)
[![PyPI - Version](https://img.shields.io/pypi/v/staged-script?label=PyPI)](https://pypi.org/project/staged-script/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/staged-script?label=PyPI%20downloads)
![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)
![Python Version](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-blue.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

# staged-script
Expand All @@ -44,7 +44,6 @@ python3 -m pip install staged-script
Once installed, you can simply
```python
import sys
from typing import List

from staged_script import StagedScript

Expand All @@ -59,7 +58,7 @@ class MyScript(StagedScript):
def say_goodbye(self) -> None:
self.run("echo 'Goodbye World'", shell=True)

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
16 changes: 8 additions & 8 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ simple stages to say "hello" and "goodbye".
:language: python
:linenos:
:lines: 10-
:emphasize-lines: 9-10,13-14,19-20
:emphasize-lines: 8-9,12-13,18-19
:caption: ``example/ex_0_the_basics.py``

The two methods ``say_hello()`` and ``say_goodbye()`` are stand-ins for
Expand Down Expand Up @@ -73,7 +73,7 @@ by adding the following to the ``MyScript`` class:
.. literalinclude:: ../../example/ex_1_removing_the_retry_arguments.py
:language: python
:linenos:
:lines: 28-40
:lines: 27-39
:caption: ``example/ex_1_removing_the_retry_arguments.py``

.. note::
Expand Down Expand Up @@ -109,7 +109,7 @@ that case, you can add the highlighted line:
.. literalinclude:: ../../example/ex_2_running_certain_stages_by_default.py
:language: python
:linenos:
:lines: 28-30,42-43
:lines: 27-29,41-42
:emphasize-lines: 4
:caption: ``example/ex_2_running_certain_stages_by_default.py``

Expand Down Expand Up @@ -138,7 +138,7 @@ Now let's see about adding some arguments to the parser beyond what
.. literalinclude:: ../../example/ex_3_adding_arguments.py
:language: python
:linenos:
:lines: 33-35,46-58
:lines: 32-34,45-57
:emphasize-lines: 4-15
:caption: ``example/ex_3_adding_arguments.py``

Expand All @@ -149,7 +149,7 @@ arguments to handle these new options. You can do so by extending the
.. literalinclude:: ../../example/ex_3_adding_arguments.py
:language: python
:linenos:
:lines: 60-71
:lines: 59-70
:caption: ``example/ex_3_adding_arguments.py``

.. note::
Expand All @@ -166,7 +166,7 @@ the two stages to take them into account.
.. literalinclude:: ../../example/ex_3_adding_arguments.py
:language: python
:linenos:
:lines: 21-31
:lines: 20-30
:emphasize-lines: 4,10
:caption: ``example/ex_3_adding_arguments.py``

Expand All @@ -193,7 +193,7 @@ overridden in your subclasses.
.. literalinclude:: ../../example/ex_4_customizing_stage_behavior.py
:language: python
:linenos:
:lines: 73-94
:lines: 72-93
:caption: ``example/ex_4_customizing_stage_behavior.py``

.. note::
Expand Down Expand Up @@ -243,7 +243,7 @@ is the name of the stage as provided to the :ref:`StagedScript.stage()
.. literalinclude:: ../../example/ex_5_customizing_individual_stages.py
:language: python
:linenos:
:lines: 96-113
:lines: 95-112
:caption: ``example/ex_5_customizing_individual_stages.py``

Now when we run both stages we see:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
.. |PyPI Version| image:: https://img.shields.io/pypi/v/staged-script?label=PyPI
:target: https://pypi.org/project/staged-script/
.. |PyPI Downloads| image:: https://img.shields.io/pypi/dm/staged-script?label=PyPI%20downloads
.. |Python Version| image:: https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg
.. |Python Version| image:: https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-blue.svg
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff

Expand Down
3 changes: 1 addition & 2 deletions example/ex_0_the_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# SPDX-License-Identifier: BSD-3-Clause

import sys
from typing import List

from staged_script import StagedScript

Expand All @@ -22,7 +21,7 @@ def say_hello(self) -> None:
def say_goodbye(self) -> None:
self.run("echo 'Goodbye World'", shell=True)

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
3 changes: 1 addition & 2 deletions example/ex_1_removing_the_retry_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import functools
import sys
from argparse import ArgumentParser
from typing import List

from staged_script import StagedScript

Expand Down Expand Up @@ -39,7 +38,7 @@ def parser(self) -> ArgumentParser:
self.goodbye_retry_timeout_arg.help = argparse.SUPPRESS # type: ignore[attr-defined]
return my_parser

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
3 changes: 1 addition & 2 deletions example/ex_2_running_certain_stages_by_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import functools
import sys
from argparse import ArgumentParser
from typing import List

from staged_script import StagedScript

Expand Down Expand Up @@ -42,7 +41,7 @@ def parser(self) -> ArgumentParser:
my_parser.set_defaults(stage=list(self.stages))
return my_parser

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
5 changes: 2 additions & 3 deletions example/ex_3_adding_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import List

from staged_script import StagedScript

Expand Down Expand Up @@ -57,7 +56,7 @@ def parser(self) -> ArgumentParser:
)
return my_parser

def parse_args(self, argv: List[str]) -> None:
def parse_args(self, argv: list[str]) -> None:
# The base class saves the parsed arguments as `self.args`.
super().parse_args(argv)

Expand All @@ -70,7 +69,7 @@ def parse_args(self, argv: List[str]) -> None:
# not.
self.args.some_file = self.args.some_file.resolve()

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
5 changes: 2 additions & 3 deletions example/ex_4_customizing_stage_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import List

from staged_script import StagedScript

Expand Down Expand Up @@ -57,7 +56,7 @@ def parser(self) -> ArgumentParser:
)
return my_parser

def parse_args(self, argv: List[str]) -> None:
def parse_args(self, argv: list[str]) -> None:
# The base class saves the parsed arguments as `self.args`.
super().parse_args(argv)

Expand Down Expand Up @@ -93,7 +92,7 @@ def _run_post_stage_actions(self) -> None:
"Checking to make sure all is well after running the stage..."
)

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
5 changes: 2 additions & 3 deletions example/ex_5_customizing_individual_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import List

from staged_script import StagedScript

Expand Down Expand Up @@ -57,7 +56,7 @@ def parser(self) -> ArgumentParser:
)
return my_parser

def parse_args(self, argv: List[str]) -> None:
def parse_args(self, argv: list[str]) -> None:
# The base class saves the parsed arguments as `self.args`.
super().parse_args(argv)

Expand Down Expand Up @@ -112,7 +111,7 @@ def _end_stage_goodbye(self) -> None:
# or `super()` calls to the default method for the corresponding
# phase, if you like.

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
8 changes: 4 additions & 4 deletions example/ex_6_creating_retryable_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import List, Optional, Set
from typing import Optional

from staged_script import RetryStage, StagedScript


class MyScript(StagedScript):
def __init__(
self,
stages: Set[str],
stages: set[str],
*,
console_force_terminal: Optional[bool] = None,
console_log_path: bool = True,
Expand Down Expand Up @@ -86,7 +86,7 @@ def parser(self) -> ArgumentParser:
)
return my_parser

def parse_args(self, argv: List[str]) -> None:
def parse_args(self, argv: list[str]) -> None:
# The base class saves the parsed arguments as `self.args`.
super().parse_args(argv)

Expand Down Expand Up @@ -141,7 +141,7 @@ def _end_stage_goodbye(self) -> None:
# or `super()` calls to the default method for the corresponding
# phase, if you like.

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
12 changes: 6 additions & 6 deletions example/ex_7_customizing_the_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
import sys
from argparse import ArgumentParser
from pathlib import Path
from typing import Dict, List, Optional, Set
from typing import Optional

from staged_script import RetryStage, StagedScript


class MyScript(StagedScript):
def __init__(
self,
stages: Set[str],
stages: set[str],
*,
console_force_terminal: Optional[bool] = None,
console_log_path: bool = True,
Expand Down Expand Up @@ -88,7 +88,7 @@ def parser(self) -> ArgumentParser:
)
return my_parser

def parse_args(self, argv: List[str]) -> None:
def parse_args(self, argv: list[str]) -> None:
# The base class saves the parsed arguments as `self.args`.
super().parse_args(argv)

Expand Down Expand Up @@ -145,7 +145,7 @@ def _end_stage_goodbye(self) -> None:

def print_script_execution_summary(
self,
extra_sections: Optional[Dict[str, str]] = None,
extra_sections: Optional[dict[str, str]] = None,
) -> None:
extras = {
"Machine details": (
Expand All @@ -154,10 +154,10 @@ def print_script_execution_summary(
),
}
if extra_sections is not None:
extras.update(extra_sections)
extras |= extra_sections
super().print_script_execution_summary(extra_sections=extras)

def main(self, argv: List[str]) -> None:
def main(self, argv: list[str]) -> None:
self.parse_args(argv)
try:
self.say_hello()
Expand Down
3 changes: 1 addition & 2 deletions example/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

import subprocess
from pathlib import Path
from typing import List


def assert_output_in_order(stdout: str, output: List[str]) -> None:
def assert_output_in_order(stdout: str, output: list[str]) -> None:
"""
Ensure the output appears in the correct order.
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
Loading

0 comments on commit a9c8005

Please sign in to comment.