Skip to content

Commit

Permalink
fix type checking for pyright
Browse files Browse the repository at this point in the history
the variable assignment of pathlib confused pyright. This is some magic
to enusre that both mypy and pyright correctly understand the type
signatures.
  • Loading branch information
jannisko committed Feb 16, 2022
1 parent b777244 commit 1ec519b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
if TYPE_CHECKING:
import paramiko.transport

# unconditionally adding pathlib here because typing only works in python3 anyways and it's in stdlib
PathTypes = Union[str, bytes, "pathlib.PurePath"]
# this is some magic to make sure pyright doesn't get too confused with pathlib potentially being a nullable variable
import pathlib
PurePath = pathlib.PurePath

PathTypes = Union[str, bytes, PurePath]
except ImportError:
pass

Expand Down

0 comments on commit 1ec519b

Please sign in to comment.