Skip to content

Commit

Permalink
Use | None instead of Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlind committed Nov 2, 2023
1 parent ef4a28c commit a8560be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import re
import sys
from typing import Optional

from setuptools import Command, find_packages, setup

Expand Down Expand Up @@ -42,7 +41,7 @@ def run(self):
sys.exit(info)


def _validate_version(tag: Optional[str], version: str) -> bool:
def _validate_version(tag: str | None, version: str) -> bool:
if not tag:
return version == "0.0.0"
if tag[0] != "v":
Expand Down
19 changes: 9 additions & 10 deletions voight_kampff/task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Task specification."""
import subprocess # nosec
from pathlib import Path
from typing import List, Optional
from typing import List


class Task:
Expand All @@ -11,28 +11,27 @@ class Task:

title: str
_command: str
_glob_file_type: Optional[str]
_glob_file_type: str | None
_args: List[str]

def __init__(
self,
title: str,
command: str,
args: Optional[List[str]] = None,
glob_file_type: Optional[str] = None,
args: List[str] | None = None,
glob_file_type: str | None = None,
):
"""
Initialize a new task specification.
Args:
title (str): Title of the task for showing in CLI
command (str): name of command to run.
args (List[str], optional): CLI arguments. Should not include arguments
specifying what files to process. Defaults to None.
glob_file_type (Optional[str], optional): The base folder will be searched
for files of this type and they will be added as arguments. Defaults to
args (List[str] | None, optional): CLI arguments. Should not include
arguments specifying what files to process. Defaults to None.
glob_file_type (str | None, optional): The base folder will be searched for
files of this type and they will be added as arguments. Defaults to
None.
"""
self.title = title
self._command = command
Expand Down Expand Up @@ -71,7 +70,7 @@ def run(self) -> int:
print("")
return process.returncode

def _list_files(self, base_folder: Optional[Path] = None) -> List[str]:
def _list_files(self, base_folder: Path | None = None) -> List[str]:
if not self._glob_file_type:
return []

Expand Down

0 comments on commit a8560be

Please sign in to comment.