Skip to content

Commit

Permalink
(chore): remove py3.11 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Nov 15, 2024
1 parent b891b7c commit 7ab8eee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 52 deletions.
7 changes: 1 addition & 6 deletions ci/scripts/min-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
from __future__ import annotations

import argparse
import sys
import tomllib
from collections import deque
from pathlib import Path
from typing import TYPE_CHECKING

if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib

from packaging.requirements import Requirement
from packaging.version import Version

Expand Down
28 changes: 7 additions & 21 deletions src/anndata/_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import inspect
import os
import sys
import textwrap
import warnings
from collections.abc import Iterable
Expand Down Expand Up @@ -53,27 +52,14 @@ def describe(self: RegisteredOption, *, as_rst: bool = False) -> str:
return textwrap.dedent(doc)


if sys.version_info >= (3, 11):

class RegisteredOption(NamedTuple, Generic[T]):
option: str
default_value: T
description: str
validate: Callable[[T], None]
type: object

describe = describe

else:

class RegisteredOption(NamedTuple):
option: str
default_value: T
description: str
validate: Callable[[T], None]
type: object
class RegisteredOption(NamedTuple, Generic[T]):
option: str
default_value: T
description: str
validate: Callable[[T], None]
type: object

describe = describe
describe = describe


def check_and_get_environ_var(
Expand Down
24 changes: 0 additions & 24 deletions src/anndata/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
from __future__ import annotations

import os
import sys
from codecs import decode
from collections.abc import Mapping
from contextlib import AbstractContextManager
from dataclasses import dataclass, field
from functools import singledispatch, wraps
from importlib.util import find_spec
from inspect import Parameter, signature
from pathlib import Path
from types import EllipsisType
from typing import TYPE_CHECKING, TypeVar
from warnings import warn
Expand All @@ -20,8 +15,6 @@
import scipy
from packaging.version import Version

from .exceptiongroups import add_note # noqa: F401

if TYPE_CHECKING:
from typing import Any

Expand Down Expand Up @@ -69,23 +62,6 @@ class Empty:
#############################


if sys.version_info >= (3, 11):
from contextlib import chdir
else:

@dataclass
class chdir(AbstractContextManager):
path: Path
_old_cwd: list[Path] = field(default_factory=list)

def __enter__(self) -> None:
self._old_cwd.append(Path())
os.chdir(self.path)

def __exit__(self, *_exc_info) -> None:
os.chdir(self._old_cwd.pop())


#############################
# Optional deps
#############################
Expand Down
3 changes: 2 additions & 1 deletion src/testing/anndata/_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def _doctest_env(
)
from scanpy import settings

from anndata.compat import chdir
from contextlib import chdir

from anndata.utils import import_name

assert isinstance(request.node.parent, pytest.Module)
Expand Down

0 comments on commit 7ab8eee

Please sign in to comment.