Skip to content

Commit 877b1b6

Browse files
wchschloerke
andauthored
Remove Python 3.7 support and conditional code (#590)
Co-authored-by: Barret Schloerke <[email protected]>
1 parent 6d7c7e9 commit 877b1b6

34 files changed

+46
-89
lines changed

.github/workflows/pytest.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
# "3.10" must be a string; otherwise it is interpreted as 3.1.
17-
python-version: ["3.11", "3.10", "3.9", "3.8", "3.7"]
17+
python-version: ["3.11", "3.10", "3.9", "3.8"]
1818
os: [ubuntu-latest, windows-latest, macOS-latest]
1919
fail-fast: false
2020

@@ -32,7 +32,7 @@ jobs:
3232
make test
3333
3434
- name: Type check with pyright
35-
if: matrix.python-version != '3.7' && steps.install.outcome == 'success' && (success() || failure())
35+
if: steps.install.outcome == 'success' && (success() || failure())
3636
run: |
3737
make pyright
3838
@@ -51,7 +51,7 @@ jobs:
5151
if: github.event_name != 'release'
5252
strategy:
5353
matrix:
54-
python-version: ["3.11", "3.10", "3.9", "3.8", "3.7"]
54+
python-version: ["3.11", "3.10", "3.9", "3.8"]
5555
os: [ubuntu-latest]
5656
fail-fast: false
5757

@@ -71,7 +71,7 @@ jobs:
7171
if: github.event_name != 'release'
7272
strategy:
7373
matrix:
74-
python-version: ["3.11", "3.10", "3.9", "3.8", "3.7"]
74+
python-version: ["3.11", "3.10", "3.9", "3.8"]
7575
os: [ubuntu-latest]
7676
fail-fast: false
7777

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Other changes
1616

17+
* Removed Python 3.7 support. (#590)
18+
1719

1820
## [0.4.0] - 2023-06-26
1921

e2e/controls.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@
77
import sys
88
import time
99
import typing
10+
from typing import Literal, Protocol
1011

1112
from playwright.sync_api import FilePayload, FloatRect, Locator, Page, Position
1213
from playwright.sync_api import expect as playwright_expect
1314

1415
# Import `shiny`'s typing extentions.
1516
# Since this is a private file, tell pyright to ignore the import
1617
# (Imports split over many import statements due to auto formatting)
17-
from shiny._typing_extensions import (
18-
Literal, # pyright: ignore[reportPrivateImportUsage]
19-
)
20-
from shiny._typing_extensions import (
21-
Protocol, # pyright: ignore[reportPrivateImportUsage]
22-
)
2318
from shiny._typing_extensions import (
2419
TypeGuard, # pyright: ignore[reportPrivateImportUsage]
2520
)

e2e/inputs/test_input_date.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import datetime
44
import typing
5+
from typing import Literal
56

67
from conftest import ShinyAppProc, create_doc_example_fixture
78
from controls import InputDate
89
from playwright.sync_api import Page, expect
910

10-
from shiny._typing_extensions import (
11-
Literal, # pyright: ignore[reportPrivateImportUsage]
12-
)
13-
1411
app = create_doc_example_fixture("input_date")
1512

1613

e2e/inputs/test_input_date_range.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
import datetime
44
import typing
5+
from typing import Literal
56

67
from conftest import ShinyAppProc, create_doc_example_fixture
78
from controls import InputDateRange
89
from playwright.sync_api import Page, expect
910

10-
from shiny._typing_extensions import (
11-
Literal, # pyright: ignore[reportPrivateImportUsage]
12-
)
13-
1411
app = create_doc_example_fixture("input_date_range")
1512

1613

setup.cfg

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ classifiers =
1515
Intended Audience :: Developers
1616
License :: OSI Approved :: MIT License
1717
Natural Language :: English
18-
Programming Language :: Python :: 3.7
1918
Programming Language :: Python :: 3.8
2019
Programming Language :: Python :: 3.9
2120
Programming Language :: Python :: 3.10
@@ -26,7 +25,7 @@ project_urls =
2625
Source Code = https://github.com/rstudio/py-shiny
2726

2827
[options]
29-
python_requires = >=3.7
28+
python_requires = >=3.8
3029
packages = find_namespace:
3130
test_suite = tests
3231
include_package_data = True
@@ -50,7 +49,6 @@ install_requires =
5049
appdirs>=1.4.4
5150
asgiref>=3.5.2
5251
watchfiles>=0.18.0;platform_system!="Emscripten"
53-
importlib-metadata>=1.1.0,<5;python_version<"3.8"
5452
tests_require =
5553
pytest>=3
5654
zip_safe = False
@@ -76,9 +74,7 @@ test =
7674
plotly
7775
dev =
7876
black>=23.1.0
79-
# Python 3.7 needs a specific version of flake8 to satisfy other dependencies.
80-
flake8==3.9.2;python_version<="3.7"
81-
flake8>=6.0.0;python_version>"3.7"
77+
flake8>=6.0.0
8278
flake8-bugbear>=23.2.13
8379
isort>=5.10.1
8480
# pyright produces break changes rapidly. Fix to a particular version

shiny/_docstring.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import json
44
import os
5-
from typing import Any, Callable, TypeVar
6-
7-
from ._typing_extensions import Literal
5+
from typing import Any, Callable, Literal, TypeVar
86

97
ex_dir: str = os.path.join(os.path.dirname(os.path.abspath(__file__)), "examples")
108

shiny/_typing_extensions.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55

66
import sys
77

8-
if sys.version_info >= (3, 8):
9-
from typing import Literal, Protocol, runtime_checkable
10-
else:
11-
from typing_extensions import Literal, Protocol, runtime_checkable
12-
138
if sys.version_info >= (3, 10):
149
from typing import Concatenate, ParamSpec, TypeGuard
1510
else:
@@ -28,4 +23,4 @@
2823
# conditional imports into the .pyi file when generating type stubs. Without this line,
2924
# pyright will not include the above imports in the generated .pyi file, and it will
3025
# result in a lot of red squiggles in user code.
31-
_: 'Literal | Protocol | runtime_checkable | Concatenate[str, ParamSpec("P")] | ParamSpec | TypeGuard | NotRequired | TypedDict | assert_type' # type:ignore
26+
_: 'Concatenate[str, ParamSpec("P")] | ParamSpec | TypeGuard | NotRequired | TypedDict | assert_type' # type:ignore

shiny/_utils.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@
1010
import random
1111
import secrets
1212
import socketserver
13-
import sys
1413
import tempfile
1514
from typing import Any, Awaitable, Callable, Optional, TypeVar, cast
1615

1716
from ._typing_extensions import ParamSpec, TypeGuard
1817

19-
if sys.version_info >= (3, 8):
20-
CancelledError = asyncio.CancelledError
21-
else:
22-
CancelledError = asyncio.futures.CancelledError
18+
CancelledError = asyncio.CancelledError
2319

2420

2521
# ==============================================================================
@@ -62,12 +58,8 @@ def guess_mime_type(
6258
Guess the MIME type of a file. This is a wrapper for mimetypes.guess_type, but it
6359
only returns the type (and not encoding), and it allows a default value.
6460
"""
65-
# In Python<=3.7, mimetypes.guess_type only accepts strings.
66-
#
6761
# Note that in the parameters above, "os.PathLike[str]" is in quotes to avoid
6862
# "TypeError: 'ABCMeta' object is not subscriptable", in Python<=3.8.
69-
if sys.version_info < (3, 8):
70-
url = os.fspath(url)
7163
return mimetypes.guess_type(url, strict)[0] or default
7264

7365

shiny/experimental/ui/_accordion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from __future__ import annotations
22

33
import random
4-
from typing import Optional, TypeVar
4+
from typing import Literal, Optional, TypeVar
55

66
from htmltools import Tag, TagAttrs, TagAttrValue, TagChild, css, tags
77

88
from ... import Session
9-
from ..._typing_extensions import Literal
109
from ..._utils import drop_none
1110
from ...session import require_active_session
1211
from ...types import MISSING, MISSING_TYPE

0 commit comments

Comments
 (0)