Skip to content

Commit

Permalink
Merge pull request #417 from py-mine/remove-py37
Browse files Browse the repository at this point in the history
Remove all 3.7 support
  • Loading branch information
kevinkjt2000 authored Oct 19, 2022
2 parents 99ae9ed + fc3e0eb commit 149a5a8
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: Checkout repository
Expand Down
68 changes: 11 additions & 57 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -29,7 +28,7 @@ packages = [
]

[tool.poetry.dependencies]
python = ">=3.7,<4"
python = ">=3.8,<4"
asyncio-dgram = "2.1.2"
dnspython = "2.2.1"

Expand All @@ -52,7 +51,7 @@ flake8-annotations = "^2.9.1"
flake8-bugbear = "^22.9.23"
flake8-tidy-imports = "^4.8.0"
flake8-pep585 = {version = "^0.1.6", python = ">=3.9"}
flake8-new-union-types = {version = "^0.4.1", python = ">=3.8"}
flake8-new-union-types = "^0.4.1"
flake8-future-annotations = "^1.0.0"
isort = "^5.10.1"
pep8-naming = "^0.13.2"
Expand Down
22 changes: 2 additions & 20 deletions tests/test_address.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

import ipaddress
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import TypeVar
from unittest.mock import MagicMock, Mock, patch

import dns.resolver
Expand All @@ -12,22 +10,6 @@

from mcstatus.address import Address, async_minecraft_srv_address_lookup, minecraft_srv_address_lookup

T = TypeVar("T")


def const_coro(value: T) -> Callable[..., Awaitable[T]]:
"""This is a helper function, which returns an async func returning value.
This is needed because in python 3.7, Mock.return_value didn't properly cover
async functions, which means we need to do Mock.side_effect = some_coro. This
function just makes it easy to quickly construct these coroutines.
"""

async def inner(*a, **kw) -> T:
return value

return inner


class TestSRVLookup:
@pytest.mark.parametrize("exception", [dns.resolver.NXDOMAIN, dns.resolver.NoAnswer])
Expand Down Expand Up @@ -69,7 +51,7 @@ async def test_async_address_with_srv(self):
answer = Mock()
answer.target = "different.example.org."
answer.port = 12345
resolve.side_effect = const_coro([answer])
resolve.return_value = [answer]

address = await async_minecraft_srv_address_lookup("example.org", lifetime=3)
resolve.assert_called_once_with("_minecraft._tcp.example.org", RdataType.SRV, lifetime=3)
Expand Down Expand Up @@ -183,7 +165,7 @@ async def test_async_ip_resolver_with_hostname(self):
with patch("dns.asyncresolver.resolve") as resolve:
answer = MagicMock()
answer.__str__.return_value = "48.225.1.104."
resolve.side_effect = const_coro([answer])
resolve.return_value = [answer]

resolved_ip = await self.host_addr.async_resolve_ip(lifetime=3)

Expand Down
6 changes: 1 addition & 5 deletions tests/test_timeout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import typing
from asyncio.exceptions import TimeoutError
from unittest.mock import patch

import pytest
Expand All @@ -24,11 +25,6 @@ def setup_method(self):
self.test_addr = Address("dummy_address", 1234)

def test_tcp_socket_read(self):
try:
from asyncio.exceptions import TimeoutError # type: ignore # (Import for older versions)
except ImportError:
from asyncio import TimeoutError

with patch("asyncio.open_connection", fake_asyncio_asyncio_open_connection):
asyncio.run(self.tcp_async_socket.connect(self.test_addr, timeout=0.01))

Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[tox]
isolated_build = True
envlist =
format-check,lint,py{37,38,39,310},coverage
format-check,lint,py{38,39,310},coverage

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, coverage
Expand Down Expand Up @@ -34,7 +33,7 @@ commands =

[testenv:coverage]
depends =
py{37,38,39,310}
py{38,39,310}
setenv =
COVERAGE_FILE=.coverage
commands =
Expand Down

0 comments on commit 149a5a8

Please sign in to comment.