Skip to content

Commit dc6f8f7

Browse files
committed
Added new typing module with "PathLike" typing alias in it
1 parent 9858092 commit dc6f8f7

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

domdf_python_tools/paths.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
import pathlib
4949
import shutil
5050
import stat
51-
from typing import IO, Callable, Optional, Union
51+
from typing import IO, Callable, Optional
5252

53-
PathLike = Union[str, pathlib.Path, os.PathLike]
53+
# this package
54+
from domdf_python_tools.typing import PathLike
5455

5556

5657
def append(var: str, filename: PathLike):

domdf_python_tools/terminal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
3434
# MA 02110-1301, USA.
3535
#
36-
# Based on ChemPy (https://github.com/bjodah/chempy)
36+
# "Echo" based on ChemPy (https://github.com/bjodah/chempy)
3737
# | Copyright (c) 2015-2018, Björn Dahlgren
3838
# | All rights reserved.
3939
# |
@@ -202,6 +202,7 @@ def _get_terminal_size_tput() -> Optional[Tuple[int, int]]:
202202

203203

204204
def _get_terminal_size_posix() -> Optional[Tuple[int, int]]:
205+
205206
# stdlib
206207
import fcntl
207208
import termios

domdf_python_tools/typing.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
#
3+
# typing.py
4+
"""
5+
Common aliases for type hinting
6+
"""
7+
#
8+
# Copyright © 2020 Dominic Davis-Foster <[email protected]>
9+
#
10+
# This program is free software; you can redistribute it and/or modify
11+
# it under the terms of the GNU Lesser General Public License as published by
12+
# the Free Software Foundation; either version 3 of the License, or
13+
# (at your option) any later version.
14+
#
15+
# This program is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU Lesser General Public License for more details.
19+
#
20+
# You should have received a copy of the GNU Lesser General Public License
21+
# along with this program; if not, write to the Free Software
22+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23+
# MA 02110-1301, USA.
24+
#
25+
26+
# stdlib
27+
import os
28+
import pathlib
29+
from typing import Union
30+
31+
PathLike = Union[str, pathlib.Path, os.PathLike]

0 commit comments

Comments
 (0)