Skip to content

Commit

Permalink
Drop python 3.7 support and add 3.11 support (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsahovic committed Aug 13, 2023
1 parent f141fa4 commit 09964f3
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
version: ['3.7', '3.8', '3.9', '3.10']
version: ['3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout repository code
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ These steps are not required, but are useful if you are unsure where to start.

First, you should use a python virtual environment. Which flavor of virtual environment you want to use depends on a couple things, including personal habits and your OS of choice. On Windows, [we recommend using `anaconda`](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html). On Mac OS and Linux, [`pyenv` works very well](https://github.com/pyenv/pyenv).

This project supports multiple versions of python 3, starting from version 3.7. You can use any supported version for development, but bear in mind that your work will be tested on all supported versions.
This project supports multiple versions of python 3, starting from version 3.8. You can use any supported version for development, but bear in mind that your work will be tested on all supported versions.

Once you have created your virtual environment, install dependencies with `pip install -r requirements.txt` and `pip install -r requirements-dev.txt`. You can now setup pre-commits by running `pre-commit install` - the pre-commit configuration on the repo supposes Python 3.10.5, but you can modify it locally to your liking.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Documentation, detailed examples and starting code can be found [on readthedocs]

## Installation

This project requires python >= 3.7 and a [Pokemon Showdown](https://github.com/Zarel/Pokemon-Showdown) server.
This project requires python >= 3.8 and a [Pokemon Showdown](https://github.com/Zarel/Pokemon-Showdown) server.

```
pip install poke-env
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This sections will guide you in installing ``poke-env`` and configuring a suited
Installing ``poke-env``
=======================

``poke-env`` requires python >= 3.7 to be installed. It has a number of dependencies that are listed `here <https://github.com/hsahovic/poke-env/blob/master/requirements.txt>`__ and that will be installed automatically.
``poke-env`` requires python >= 3.8 to be installed. It has a number of dependencies that are listed `here <https://github.com/hsahovic/poke-env/blob/master/requirements.txt>`__ and that will be installed automatically.

Installation can be performed via pip:

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "poke_env"
version = "0.7.1"
description = "A python interface for training Reinforcement Learning bots to battle on pokemon showdown."
readme = "README.md"
requires-python = ">=3.7.0"
requires-python = ">=3.8.0"
license = { file = "LICENSE" }
authors = [{ name = "Haris Sahovic", email = "contact@sahovic.fr" }]
classifiers = [
Expand All @@ -17,10 +17,10 @@ classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Games/Entertainment :: Simulation",
"Topic :: Games/Entertainment :: Turn Based Strategy",
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
asynctest
black==23.3.0
flake8
isort==5.9.0
Expand Down
4 changes: 0 additions & 4 deletions src/poke_env/player/player_network_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ def __init__(
@staticmethod
def _create_class(cls, *args, **kwargs): # pragma: no cover
try:
# Python >= 3.7
loop = asyncio.get_running_loop()
except AttributeError:
# Python < 3.7 so get_event_loop won't raise exceptions
loop = asyncio.get_event_loop()
except RuntimeError:
# asyncio.get_running_loop raised exception so no loop is running
loop = None
Expand Down
22 changes: 11 additions & 11 deletions unit_tests/player/test_player_network_interface.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import asyncio
import logging
from collections import namedtuple
from unittest.mock import AsyncMock, PropertyMock, patch

import pytest
import websockets
from asynctest.mock import CoroutineMock, PropertyMock, patch

from poke_env import PlayerConfiguration, ServerConfiguration
from poke_env.player import PlayerNetwork
Expand Down Expand Up @@ -67,8 +67,8 @@ async def test_log_in(post_mock):
start_listening=False,
)

player._send_message = CoroutineMock()
player._change_avatar = CoroutineMock()
player._send_message = AsyncMock()
player._change_avatar = AsyncMock()

await player._log_in(["A", "B", "C", "D"])

Expand All @@ -86,7 +86,7 @@ async def test_change_avatar():
start_listening=False,
)

player._send_message = CoroutineMock()
player._send_message = AsyncMock()
player._logged_in.set()

await player._change_avatar(8)
Expand All @@ -102,7 +102,7 @@ async def test_handle_message():
server_configuration=server_configuration,
start_listening=False,
)
player._log_in = CoroutineMock()
player._log_in = AsyncMock()

await player._handle_message("|challstr")
player._log_in.assert_called_once()
Expand All @@ -111,17 +111,17 @@ async def test_handle_message():
await player._handle_message("|updateuser| username")
assert player._logged_in.is_set() is True

player._update_challenges = CoroutineMock()
player._update_challenges = AsyncMock()
await player._handle_message("|updatechallenges")
player._update_challenges.assert_called_once_with(["", "updatechallenges"])

player._handle_battle_message = CoroutineMock()
player._handle_battle_message = AsyncMock()
await player._handle_message(">battle|thing")
player._handle_battle_message.assert_called_once_with([[">battle", "thing"]])

await player._handle_message("|updatesearch")

player._logger.warning = CoroutineMock()
player._logger.warning = AsyncMock()
await player._handle_message("that was unexpected!|")
player._logger.warning.assert_called_once_with(
"Unhandled message: %s", "that was unexpected!|"
Expand All @@ -139,7 +139,7 @@ async def test_listen():

type(player).websocket_url = PropertyMock(return_value="ws://localhost:8899")

player._handle_message = CoroutineMock()
player._handle_message = AsyncMock()
semaphore = asyncio.Semaphore()

async def showdown_server_mock(websocket, path):
Expand Down Expand Up @@ -168,8 +168,8 @@ async def test_send_message():
server_configuration=server_configuration,
start_listening=False,
)
player._websocket = CoroutineMock()
player._websocket.send = CoroutineMock()
player._websocket = AsyncMock()
player._websocket.send = AsyncMock()

await player._send_message("hey", "home")
player._websocket.send.assert_called_once_with("home|hey")
Expand Down

0 comments on commit 09964f3

Please sign in to comment.