Skip to content

Commit

Permalink
Remove Python 3.8 workarounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Oct 7, 2024
1 parent 7c6bed3 commit 5296add
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 28 deletions.
4 changes: 2 additions & 2 deletions core/src/toga/command.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator
from typing import TYPE_CHECKING, MutableMapping, MutableSet, Protocol
from collections.abc import Iterator, MutableMapping, MutableSet
from typing import TYPE_CHECKING, Protocol

from toga.handlers import simple_handler, wrapped_handler
from toga.icons import Icon
Expand Down
19 changes: 4 additions & 15 deletions core/src/toga/documents.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import annotations

import itertools
import sys
from abc import ABC, abstractmethod
from collections.abc import Iterator
from collections.abc import Iterator, Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Mapping, Sequence
from typing import TYPE_CHECKING

import toga
from toga import dialogs
Expand Down Expand Up @@ -225,12 +224,7 @@ def __getitem__(self, path_or_index):
return self.elements[path_or_index]

# Look up by path
if sys.version_info < (3, 9): # pragma: no-cover-if-gte-py39
# resolve() *should* turn the path into an absolute path;
# but on Windows, with Python 3.8, it doesn't.
path = Path(path_or_index).absolute().resolve()
else: # pragma: no-cover-if-lt-py39
path = Path(path_or_index).resolve()
path = Path(path_or_index).resolve()
for item in self.elements:
if item.path == path:
return item
Expand Down Expand Up @@ -320,12 +314,7 @@ def open(self, path: Path | str) -> Document:
match a registered document type.
"""
try:
if sys.version_info < (3, 9): # pragma: no-cover-if-gte-py39
# resolve() *should* turn the path into an absolute path;
# but on Windows, with Python 3.8, it doesn't.
path = Path(path).absolute().resolve()
else: # pragma: no-cover-if-lt-py39
path = Path(path).resolve()
path = Path(path).resolve()
document = self.app.documents[path]
document.focus()
return document
Expand Down
3 changes: 1 addition & 2 deletions core/src/toga/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import traceback
import warnings
from abc import ABC
from collections.abc import Awaitable, Generator
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Callable,
Generator,
NoReturn,
Protocol,
TypeVar,
Expand Down
4 changes: 2 additions & 2 deletions core/src/toga/sources/tree_source.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator
from typing import Iterable, Mapping, TypeVar
from collections.abc import Iterable, Iterator, Mapping
from typing import TypeVar

from .base import Source
from .list_source import Row, _find_item
Expand Down
4 changes: 2 additions & 2 deletions core/src/toga/statusicons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import sys
from abc import abstractmethod
from collections.abc import Iterator
from typing import TYPE_CHECKING, Mapping, Sequence
from collections.abc import Iterator, Mapping, Sequence
from typing import TYPE_CHECKING

import toga
from toga.command import Command, CommandSet, Group
Expand Down
4 changes: 2 additions & 2 deletions core/src/toga/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import warnings
from builtins import id as identifier
from collections.abc import Coroutine, Iterator
from collections.abc import Coroutine, Iterator, MutableSet
from pathlib import Path
from typing import TYPE_CHECKING, Any, MutableSet, Protocol, TypeVar
from typing import TYPE_CHECKING, Any, Protocol, TypeVar

import toga
from toga import dialogs
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ no-cover-if-lt-py311 = "sys_version_info < (3, 11) and os_environ.get('COVERAGE_
no-cover-if-gte-py311 = "sys_version_info > (3, 11) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py310 = "sys_version_info < (3, 10) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py310 = "sys_version_info > (3, 10) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-lt-py39 = "sys_version_info < (3, 9) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"
no-cover-if-gte-py39 = "sys_version_info > (3, 9) and os_environ.get('COVERAGE_EXCLUDE_PYTHON_VERSION') != 'disable'"


[tool.isort]
profile = "black"
Expand Down

0 comments on commit 5296add

Please sign in to comment.