From c67dde8ed058ec1f31774f4b35424becc6202d27 Mon Sep 17 00:00:00 2001 From: Kevin Tindall Date: Sun, 2 Jan 2022 21:29:06 -0600 Subject: [PATCH] Removed usage of six Credit goes to ItsDrike 87870ddf1748bdfa7d706f61758b04fc781d7dc1 #182 --- mcstatus/pinger.py | 14 +++++--------- poetry.lock | 10 +++++----- pyproject.toml | 1 - 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mcstatus/pinger.py b/mcstatus/pinger.py index 8617c46..e3c09c8 100644 --- a/mcstatus/pinger.py +++ b/mcstatus/pinger.py @@ -3,8 +3,6 @@ import json import random from typing import List, Optional -from six import string_types - from mcstatus.protocol.connection import Connection COLOR_MAP = { @@ -89,8 +87,7 @@ class ServerPinger: ) delta = received - sent - # We have no trivial way of getting a time delta :( - return (delta.days * 24 * 60 * 60 + delta.seconds) * 1000 + delta.microseconds / 1000.0 + return delta.total_seconds() * 1000 class AsyncServerPinger(ServerPinger): @@ -129,8 +126,7 @@ class AsyncServerPinger(ServerPinger): ) delta = received - sent - # We have no trivial way of getting a time delta :( - return (delta.days * 24 * 60 * 60 + delta.seconds) * 1000 + delta.microseconds / 1000.0 + return delta.total_seconds() * 1000 class PingResponse: @@ -147,13 +143,13 @@ class PingResponse: if "name" not in raw: raise ValueError("Invalid player object (no 'name' value)") - if not isinstance(raw["name"], string_types): + if not isinstance(raw["name"], str): raise ValueError(f"Invalid player object (expected 'name' to be str, was {type(raw['name'])}") self.name = raw["name"] if "id" not in raw: raise ValueError("Invalid player object (no 'id' value)") - if not isinstance(raw["id"], string_types): + if not isinstance(raw["id"], str): raise ValueError(f"Invalid player object (expected 'id' to be str, was {type(raw['id'])}") self.id = raw["id"] @@ -194,7 +190,7 @@ class PingResponse: if "name" not in raw: raise ValueError("Invalid version object (no 'name' value)") - if not isinstance(raw["name"], string_types): + if not isinstance(raw["name"], str): raise ValueError(f"Invalid version object (expected 'name' to be str, was {type(raw['name'])})") self.name = raw["name"] diff --git a/poetry.lock b/poetry.lock index 1348320..5c16a38 100644 --- a/poetry.lock +++ b/poetry.lock @@ -593,9 +593,9 @@ jeepney = ">=0.6" [[package]] name = "six" -version = "1.14.0" +version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" @@ -783,7 +783,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = ">=3.7,<3.10" -content-hash = "0a823ccda79fa01acc56a911a3b0a63e98b6d7b45fef2c62cafbb8a2d5839464" +content-hash = "fd8dd8e29049e857b7edf7da5803591d4eeb416e790e6eb5a9f3c9a1222de0e4" [metadata.files] asyncio-dgram = [ @@ -1144,8 +1144,8 @@ secretstorage = [ {file = "SecretStorage-3.3.1.tar.gz", hash = "sha256:fd666c51a6bf200643495a04abb261f83229dcb6fd8472ec393df7ffc8b6f195"}, ] six = [ - {file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"}, - {file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"}, + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] tabulate = [ {file = "tabulate-0.8.9-py3-none-any.whl", hash = "sha256:d7c013fe7abbc5e491394e10fa845f8f32fe54f8dc60c6622c6cf482d25d47e4"}, diff --git a/pyproject.toml b/pyproject.toml index 7c80b91..1e4a7a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,6 @@ python = ">=3.7,<3.10" asyncio-dgram = "1.2.0" click = "7.1.2" dnspython = "2.1.0" -six = "1.14.0" [tool.poetry.dev-dependencies] coverage = "^6.1.1"