Skip to content

Commit

Permalink
Remove dead code and settings (#147)
Browse files Browse the repository at this point in the history
* Reformat code according to project standards

* Drop dead code
  • Loading branch information
Secrus committed Oct 22, 2023
1 parent 5e88f1a commit c62179d
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 210 deletions.
14 changes: 0 additions & 14 deletions src/pythonfinder/_vendor/Makefile

This file was deleted.

Empty file.
Empty file.
9 changes: 0 additions & 9 deletions src/pythonfinder/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@
import sys


def is_type_checking():
try:
from typing import TYPE_CHECKING
except ImportError:
return False
return TYPE_CHECKING


def possibly_convert_to_windows_style_path(path):
if not isinstance(path, str):
path = str(path)
Expand Down Expand Up @@ -53,7 +45,6 @@ def possibly_convert_to_windows_style_path(path):


IGNORE_UNSUPPORTED = bool(os.environ.get("PYTHONFINDER_IGNORE_UNSUPPORTED", False))
MYPY_RUNNING = os.environ.get("MYPY_RUNNING", is_type_checking())
SUBPROCESS_TIMEOUT = os.environ.get("PYTHONFINDER_SUBPROCESS_TIMEOUT", 5)
"""The default subprocess timeout for determining python versions
Expand Down
5 changes: 3 additions & 2 deletions src/pythonfinder/pythonfinder.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations

import operator
from collections.abc import Iterable
from typing import Any, Optional

from .environment import set_asdf_paths, set_pyenv_paths
from .exceptions import InvalidPythonVersion
from .models.common import FinderBaseModel
from .models.path import PathEntry, SystemPath
from .models.python import PythonVersion
from .environment import set_asdf_paths, set_pyenv_paths
from .utils import Iterable, version_re
from .utils import version_re


class Finder(FinderBaseModel):
Expand Down
6 changes: 0 additions & 6 deletions src/pythonfinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ def ensure_path(path: Path | str) -> Path:
return path.absolute()


def _filter_none(k, v) -> bool:
if v:
return True
return False


def normalize_path(path: str) -> str:
return os.path.normpath(
os.path.normcase(
Expand Down
7 changes: 5 additions & 2 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
from __future__ import annotations

import re
import shutil
import sys
from pathlib import Path

import invoke
from parver import Version

from .vendoring import drop_dir

TASK_NAME = "RELEASE"


def drop_dir(path):
shutil.rmtree(str(path))


def _get_git_root(ctx):
return Path(ctx.run("git rev-parse --show-toplevel", hide=True).stdout.strip())

Expand Down
173 changes: 0 additions & 173 deletions tasks/vendoring/__init__.py

This file was deleted.

8 changes: 4 additions & 4 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
from pythonfinder.environment import possibly_convert_to_windows_style_path


@pytest.mark.skipif(os.name != 'nt', reason="Only run on Windows")
@pytest.mark.skipif(os.name != "nt", reason="Only run on Windows")
def test_possibly_convert_to_windows_style_path():
# Create a temporary directory
with tempfile.TemporaryDirectory() as tmpdirname:
# Get an input path in the form "\path\to\tempdir"
drive, tail = os.path.splitdrive(tmpdirname)
input_path = tail.replace('/', '\\')
input_path = tail.replace("/", "\\")
assert re.match(r"(\\[^/\\]+)+", input_path)
revised_path = possibly_convert_to_windows_style_path(input_path)
assert input_path == revised_path

# Get an input path in the form "/c/path/to/tempdir"
input_path = '/' + drive[0].lower() + tail.replace('\\', '/')
input_path = "/" + drive[0].lower() + tail.replace("\\", "/")
assert re.match(r"/[a-z](/[^/\\]+)+", input_path)
expected = drive.upper() + tail.replace('/', '\\')
expected = drive.upper() + tail.replace("/", "\\")
revised_path = possibly_convert_to_windows_style_path(input_path)
assert expected == revised_path

0 comments on commit c62179d

Please sign in to comment.