-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from Avasam/Pass-mypy-and-link-issues
Pass mypy and link issues
- Loading branch information
Showing
7 changed files
with
58 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import os | ||
import sys | ||
|
||
try: | ||
from jaraco.windows.filesystem import symlink | ||
except ImportError: | ||
# a dirty reimplementation of symlink from jaraco.windows | ||
from ctypes import windll | ||
from ctypes.wintypes import LPWSTR, DWORD, BOOLEAN | ||
|
||
CreateSymbolicLink = windll.kernel32.CreateSymbolicLinkW | ||
CreateSymbolicLink.argtypes = (LPWSTR, LPWSTR, DWORD) | ||
CreateSymbolicLink.restype = BOOLEAN | ||
|
||
def symlink(link, target, target_is_directory=False): | ||
""" | ||
An implementation of os.symlink for Windows (Vista and greater) | ||
""" | ||
target_is_directory = target_is_directory or os.path.isdir(target) | ||
CreateSymbolicLink(link, target, target_is_directory) | ||
|
||
|
||
assert sys.platform in ('win32',) | ||
os.makedirs(r'.\foo') | ||
assert os.path.isdir(r'.\foo') | ||
|
||
symlink(r'.\foo_sym', r'.\foo') | ||
assert os.path.isdir(r'.\foo_sym') | ||
assert os.path.islink(r'.\foo_sym') # fails | ||
import os | ||
import sys | ||
|
||
try: | ||
from jaraco.windows.filesystem import symlink | ||
except ImportError: | ||
# a dirty reimplementation of symlink from jaraco.windows | ||
from ctypes import windll | ||
from ctypes.wintypes import BOOLEAN, DWORD, LPWSTR | ||
|
||
CreateSymbolicLink = windll.kernel32.CreateSymbolicLinkW | ||
CreateSymbolicLink.argtypes = (LPWSTR, LPWSTR, DWORD) | ||
CreateSymbolicLink.restype = BOOLEAN | ||
|
||
# FIXME: link and target are inverted from jaraco.windows.filesystem | ||
# https://github.com/jaraco/jaraco.windows/issues/27 | ||
def symlink(link, target, target_is_directory=False): # type: ignore[misc] | ||
""" | ||
An implementation of os.symlink for Windows (Vista and greater) | ||
""" | ||
target_is_directory = target_is_directory or os.path.isdir(target) | ||
CreateSymbolicLink(link, target, target_is_directory) | ||
|
||
|
||
assert sys.platform in ('win32',) | ||
os.makedirs(r'.\foo') | ||
assert os.path.isdir(r'.\foo') | ||
|
||
symlink(r'.\foo_sym', r'.\foo') | ||
assert os.path.isdir(r'.\foo_sym') | ||
assert os.path.islink(r'.\foo_sym') # fails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,3 @@ formats = "zip" | |
|
||
|
||
[tool.setuptools_scm] | ||
|
||
|
||
[tool.pytest-enabler.mypy] | ||
# Disabled due to jaraco/skeleton#143 |