Skip to content

Commit

Permalink
refactor: drop 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed May 21, 2024
1 parent 0617484 commit 011ca9d
Show file tree
Hide file tree
Showing 102 changed files with 816 additions and 826 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
# TODO: Replace with macos-latest when works again.
# https://github.com/actions/setup-python/issues/808
os: [ubuntu-latest, macos-12] # eventually add `windows-latest`
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.9, "3.10", "3.11", "3.12"]

env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Read our [academic platform](https://academy.apeworx.io/) will help you master A
In the latest release, Ape requires:

- Linux or macOS
- Python 3.8 up to 3.12
- Python 3.9 up to 3.12
- **Windows**: Install Windows Subsystem Linux [(WSL)](https://docs.microsoft.com/en-us/windows/wsl/install)

Check your python version in a terminal with `python3 --version`.
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import sys
from functools import lru_cache
from pathlib import Path
from typing import List

import requests
from packaging.version import Version
Expand Down Expand Up @@ -45,7 +44,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = ["_build", ".DS_Store"]
exclude_patterns: list[str] = ["_build", ".DS_Store"]


# The suffix(es) of source filenames.
Expand Down Expand Up @@ -115,7 +114,7 @@ def fixpath(path: str) -> str:


@lru_cache(maxsize=None)
def get_versions() -> List[str]:
def get_versions() -> list[str]:
"""
Get all the versions from the Web.
"""
Expand Down
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
from pathlib import Path
from typing import Dict

from setuptools import find_packages, setup

here = Path(__file__).parent.absolute()
packages_data: Dict = {}
packages_data: dict = {}
with open(here / "src" / "ape" / "__modules__.py", encoding="utf8") as modules_file:
exec(modules_file.read(), packages_data)

Expand Down Expand Up @@ -103,7 +102,7 @@
"packaging>=23.0,<24",
"pandas>=1.3.0,<2",
"pluggy>=1.3,<2",
"pydantic>=2.5.2,<3",
"pydantic>=2.6.4,<3",
"pydantic-settings>=2.0.3,<3",
"pytest>=6.0,<8.0",
"python-dateutil>=2.8.2,<3",
Expand All @@ -128,7 +127,7 @@
"eip712>=0.2.7,<0.3",
"ethpm-types>=0.6.9,<0.7",
"eth_pydantic_types>=0.1.0,<0.2",
"evmchains>=0.0.6,<0.1",
"evmchains>=0.0.7,<0.1",
"evm-trace>=0.1.5,<0.2",
],
entry_points={
Expand All @@ -147,7 +146,7 @@
"ape_pm=ape_pm._cli:cli",
],
},
python_requires=">=3.8,<4",
python_requires=">=3.9,<4",
extras_require=extras_require,
py_modules=packages_data["__modules__"],
license="Apache-2.0",
Expand All @@ -164,7 +163,6 @@
"Operating System :: MacOS",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
11 changes: 6 additions & 5 deletions src/ape/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import re
import sys
import warnings
from collections.abc import Iterable
from gettext import gettext
from importlib.metadata import entry_points
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Tuple
from typing import Any, Optional

import click
import yaml
Expand Down Expand Up @@ -35,7 +36,7 @@ def display_config(ctx, param, value):


class ApeCLI(click.MultiCommand):
_commands: Optional[Dict] = None
_commands: Optional[dict] = None
_CLI_GROUP_NAME = "ape_cli_subcommands"

def format_commands(self, ctx, formatter) -> None:
Expand All @@ -52,7 +53,7 @@ def format_commands(self, ctx, formatter) -> None:
limit = formatter.width - 6 - max(len(cmd[0]) for cmd in commands)

# Split the commands into 3 sections.
sections: Dict[str, List[Tuple[str, str]]] = {
sections: dict[str, list[tuple[str, str]]] = {
"Core": [],
"Plugin": [],
"3rd-Party Plugin": [],
Expand Down Expand Up @@ -122,7 +123,7 @@ def _suggest_cmd(usage_error):
raise usage_error

@property
def commands(self) -> Dict:
def commands(self) -> dict:
if self._commands:
return self._commands

Expand All @@ -140,7 +141,7 @@ def commands(self) -> Dict:
self._commands = {clean_plugin_name(cmd.name): cmd.load for cmd in eps}
return self._commands

def list_commands(self, ctx) -> List[str]:
def list_commands(self, ctx) -> list[str]:
return list(sorted(self.commands))

def get_command(self, ctx, name) -> Optional[click.Command]:
Expand Down
9 changes: 5 additions & 4 deletions src/ape/api/accounts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Iterator
from pathlib import Path
from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Type, Union
from typing import TYPE_CHECKING, Any, Optional, Union

import click
from eip712.messages import EIP712Message
Expand Down Expand Up @@ -31,12 +32,12 @@ class AccountAPI(BaseInterfaceModel, BaseAddress):
An API class representing an account.
"""

def __dir__(self) -> List[str]:
def __dir__(self) -> list[str]:
"""
Display methods to IPython on ``a.[TAB]`` tab completion.
Returns:
List[str]: Method names that IPython uses for tab completion.
list[str]: Method names that IPython uses for tab completion.
"""
base_value_excludes = ("code", "codesize", "is_contract") # Not needed for accounts
base_values = [v for v in self._base_dir_values if v not in base_value_excludes]
Expand Down Expand Up @@ -407,7 +408,7 @@ class AccountContainerAPI(BaseInterfaceModel):
The path to the account's data.
"""

account_type: Type[AccountAPI]
account_type: type[AccountAPI]
"""
The type of account in this container.
See :class:`~ape.api.accounts.AccountAPI`.
Expand Down
8 changes: 4 additions & 4 deletions src/ape/api/address.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Any, List
from typing import TYPE_CHECKING, Any

from eth_pydantic_types import HexBytes

Expand All @@ -17,7 +17,7 @@ class BaseAddress(BaseInterface):
"""

@property
def _base_dir_values(self) -> List[str]:
def _base_dir_values(self) -> list[str]:
"""
This exists because when you call ``dir(BaseAddress)``, you get the type's return
value and not the instances. This allows base-classes to make use of shared
Expand Down Expand Up @@ -61,13 +61,13 @@ def __eq__(self, other: object) -> bool:
# Check other __eq__
return NotImplemented

def __dir__(self) -> List[str]:
def __dir__(self) -> list[str]:
"""
Display methods to IPython on ``a.[TAB]`` tab completion.
Overridden to lessen amount of methods shown to only those that are useful.
Returns:
List[str]: Method names that IPython uses for tab completion.
list[str]: Method names that IPython uses for tab completion.
"""
return self._base_dir_values

Expand Down
23 changes: 12 additions & 11 deletions src/ape/api/compiler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections.abc import Sequence
from functools import cached_property
from pathlib import Path
from typing import Dict, List, Optional, Sequence, Set
from typing import Optional

from eth_pydantic_types import HexBytes
from ethpm_types import ContractType
Expand Down Expand Up @@ -31,7 +32,7 @@ class CompilerAPI(BaseInterfaceModel):
this API.
"""

compiler_settings: Dict = {}
compiler_settings: dict = {}
"""
Adhoc compiler settings.
"""
Expand Down Expand Up @@ -60,7 +61,7 @@ def settings(self) -> PluginConfig:
return CustomConfig.model_validate(data)

@abstractmethod
def get_versions(self, all_paths: Sequence[Path]) -> Set[str]:
def get_versions(self, all_paths: Sequence[Path]) -> set[str]:
"""
Retrieve the set of available compiler versions for this plugin to compile ``all_paths``.
Expand All @@ -74,7 +75,7 @@ def get_versions(self, all_paths: Sequence[Path]) -> Set[str]:
@raises_not_implemented
def get_compiler_settings( # type: ignore[empty-body]
self, contract_filepaths: Sequence[Path], base_path: Optional[Path] = None
) -> Dict[Version, Dict]:
) -> dict[Version, dict]:
"""
Get a mapping of the settings that would be used to compile each of the sources
by the compiler version number.
Expand All @@ -84,13 +85,13 @@ def get_compiler_settings( # type: ignore[empty-body]
base_path (Optional[pathlib.Path]): The contracts folder base path.
Returns:
Dict[Version, Dict]: A dict of compiler settings by compiler version.
dict[Version, dict]: A dict of compiler settings by compiler version.
"""

@abstractmethod
def compile(
self, contract_filepaths: Sequence[Path], base_path: Optional[Path]
) -> List[ContractType]:
) -> list[ContractType]:
"""
Compile the given source files. All compiler plugins must implement this function.
Expand All @@ -101,7 +102,7 @@ def compile(
via ``ape compile``, gets set to the project's ``contracts/`` directory.
Returns:
List[:class:`~ape.type.contract.ContractType`]
list[:class:`~ape.type.contract.ContractType`]
"""

@raises_not_implemented
Expand Down Expand Up @@ -129,7 +130,7 @@ def compile_code( # type: ignore[empty-body]
@raises_not_implemented
def get_imports( # type: ignore[empty-body]
self, contract_filepaths: Sequence[Path], base_path: Optional[Path]
) -> Dict[str, List[str]]:
) -> dict[str, list[str]]:
"""
Returns a list of imports as source_ids for each contract's source_id in a given
compiler.
Expand All @@ -141,15 +142,15 @@ def get_imports( # type: ignore[empty-body]
via ``ape compile``, gets set to the project's ``contracts/`` directory.
Returns:
Dict[str, List[str]]: A dictionary like ``{source_id: [import_source_id, ...], ...}``
dict[str, list[str]]: A dictionary like ``{source_id: [import_source_id, ...], ...}``
"""

@raises_not_implemented
def get_version_map( # type: ignore[empty-body]
self,
contract_filepaths: Sequence[Path],
base_path: Optional[Path] = None,
) -> Dict[Version, Set[Path]]:
) -> dict[Version, set[Path]]:
"""
Get a map of versions to source paths.
Expand All @@ -160,7 +161,7 @@ def get_version_map( # type: ignore[empty-body]
``contracts_folder``.
Returns:
Dict[Version, Set[Path]]
dict[Version, set[Path]]
"""

@log_instead_of_fail(default="<CompilerAPI>")
Expand Down
8 changes: 4 additions & 4 deletions src/ape/api/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import TYPE_CHECKING, Any, Dict, Optional, TypeVar
from typing import TYPE_CHECKING, Any, Optional, TypeVar

from pydantic import ConfigDict
from pydantic_settings import BaseSettings
Expand Down Expand Up @@ -43,12 +43,12 @@ class PluginConfig(BaseSettings):

@classmethod
def from_overrides(
cls, overrides: Dict, config_manager: Optional["ConfigManager"] = None
cls, overrides: dict, config_manager: Optional["ConfigManager"] = None
) -> "PluginConfig":
cls._config_manager = config_manager
default_values = cls().model_dump()

def update(root: Dict, value_map: Dict):
def update(root: dict, value_map: dict):
for key, val in value_map.items():
if isinstance(val, dict) and key in root and isinstance(root[key], dict):
root[key] = update(root[key], val)
Expand Down Expand Up @@ -85,7 +85,7 @@ def __contains__(self, key: str) -> bool:
return key in self.__dict__ or key in (self.__pydantic_extra__ or {})

def get(self, key: str, default: Optional[ConfigItemType] = None) -> ConfigItemType:
extra: Dict = self.__pydantic_extra__ or {}
extra: dict = self.__pydantic_extra__ or {}
return self.__dict__.get(key, extra.get(key, default))


Expand Down
Loading

0 comments on commit 011ca9d

Please sign in to comment.