Skip to content
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pip: tests that rely on pip install operations"""
timeout = 300

[tool.ruff]
target-version = "py39"
target-version = "py310"
line-length = 100

[tool.ruff.lint]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"ape_pm=ape_pm._cli:cli",
],
},
python_requires=">=3.9,<4",
python_requires=">=3.10,<4",
extras_require=extras_require,
py_modules=list(_MODULES),
license="Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/ape/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from gettext import gettext
from importlib.metadata import entry_points
from pathlib import Path
from typing import Any, Optional
from typing import Any
from warnings import catch_warnings, simplefilter

import click
Expand Down Expand Up @@ -153,7 +153,7 @@ def commands(self) -> dict:
def list_commands(self, ctx) -> list[str]:
return [k for k in self.commands]

def get_command(self, ctx, name) -> Optional[click.Command]:
def get_command(self, ctx, name) -> click.Command | None:
try:
return self.commands[name]()
except Exception as err:
Expand Down
56 changes: 28 additions & 28 deletions src/ape/api/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from contextlib import contextmanager
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any

import click
from eip712.messages import EIP712Message
Expand Down Expand Up @@ -73,14 +73,14 @@ def __dir__(self) -> list[str]:
]

@property
def alias(self) -> Optional[str]:
def alias(self) -> str | None:
"""
A shortened-name for quicker access to the account.
"""
return None

@property
def public_key(self) -> Optional["HexBytes"]:
def public_key(self) -> "HexBytes | None":
"""
The public key for the account.

Expand All @@ -95,7 +95,7 @@ def prepare_transaction(self, txn: "TransactionAPI", **kwargs) -> "TransactionAP
prepared_tx = super().prepare_transaction(txn, **kwargs)
return (self.sign_transaction(prepared_tx) or prepared_tx) if sign else prepared_tx

def sign_raw_msghash(self, msghash: "HexBytes") -> Optional[MessageSignature]:
def sign_raw_msghash(self, msghash: "HexBytes") -> MessageSignature | None:
"""
Sign a raw message hash.

Expand All @@ -115,19 +115,19 @@ def sign_raw_msghash(self, msghash: "HexBytes") -> Optional[MessageSignature]:
def sign_authorization(
self,
address: Any,
chain_id: Optional[int] = None,
nonce: Optional[int] = None,
) -> Optional[MessageSignature]:
chain_id: int | None = None,
nonce: int | None = None,
) -> MessageSignature | None:
"""
Sign an `EIP-7702 <https://eips.ethereum.org/EIPS/eip-7702>`__ Authorization.

Args:
address (Any): A delegate address to sign the authorization for.
chain_id (Optional[int]):
chain_id (int | None):
The chain ID that the authorization should be valid for.
A value of ``0`` means that the authorization is valid for **any chain**.
Default tells implementation to use the currently connected network's ``chain_id``.
nonce (Optional[int]):
nonce (int | None):
The nonce to use to sign authorization with. Defaults to account's current nonce.

Returns:
Expand All @@ -146,7 +146,7 @@ def sign_authorization(
)

@abstractmethod
def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]:
def sign_message(self, msg: Any, **signer_options) -> MessageSignature | None:
"""
Sign a message.

Expand All @@ -164,7 +164,7 @@ def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]
"""

@abstractmethod
def sign_transaction(self, txn: TransactionAPI, **signer_options) -> Optional[TransactionAPI]:
def sign_transaction(self, txn: TransactionAPI, **signer_options) -> TransactionAPI | None:
"""
Sign a transaction.

Expand Down Expand Up @@ -259,9 +259,9 @@ def call(

def transfer(
self,
account: Union[str, AddressType, BaseAddress],
value: Optional[Union[str, int]] = None,
data: Optional[Union[bytes, str]] = None,
account: str | AddressType | BaseAddress,
value: str | int | None = None,
data: bytes | str | None = None,
private: bool = False,
**kwargs,
) -> ReceiptAPI:
Expand All @@ -273,9 +273,9 @@ def transfer(
and using a provider that does not support private transactions.

Args:
account (Union[str, AddressType, BaseAddress]): The receiver of the funds.
value (Optional[Union[str, int]]): The amount to send.
data (Optional[Union[bytes, str]]): Extra data to include in the transaction.
account (str | AddressType | BaseAddress): The receiver of the funds.
value (str | int | None): The amount to send.
data (bytes | str | None): Extra data to include in the transaction.
private (bool): ``True`` asks the provider to make the transaction
private. For example, EVM providers typically use the RPC
``eth_sendPrivateTransaction`` to achieve this. Local providers may ignore
Expand Down Expand Up @@ -412,8 +412,8 @@ def declare(self, contract: "ContractContainer", *args, **kwargs) -> ReceiptAPI:

def check_signature(
self,
data: Union[SignableMessage, TransactionAPI, str, EIP712Message, int, bytes],
signature: Optional[MessageSignature] = None, # TransactionAPI doesn't need it
data: SignableMessage | TransactionAPI | str | EIP712Message | int | bytes,
signature: MessageSignature | None = None, # TransactionAPI doesn't need it
recover_using_eip191: bool = True,
) -> bool:
"""
Expand All @@ -422,7 +422,7 @@ def check_signature(
Args:
data (Union[:class:`~ape.types.signatures.SignableMessage`, :class:`~ape.api.transactions.TransactionAPI`]): # noqa: E501
The message or transaction to verify.
signature (Optional[:class:`~ape.types.signatures.MessageSignature`]):
signature (MessageSignature | None):
The signature to check. Defaults to ``None`` and is not needed when the first
argument is a transaction class.
recover_using_eip191 (bool):
Expand Down Expand Up @@ -459,7 +459,7 @@ def check_signature(
else:
raise AccountsError(f"Unsupported message type: {type(data)}.")

def get_deployment_address(self, nonce: Optional[int] = None) -> AddressType:
def get_deployment_address(self, nonce: int | None = None) -> AddressType:
"""
Get a contract address before it is deployed. This is useful
when you need to pass the contract address to another contract
Expand All @@ -481,7 +481,7 @@ def get_deployment_address(self, nonce: Optional[int] = None) -> AddressType:
nonce = self.nonce if nonce is None else nonce
return ecosystem.get_deployment_address(self.address, nonce)

def set_delegate(self, contract: Union[BaseAddress, AddressType, str], **txn_kwargs):
def set_delegate(self, contract: BaseAddress | AddressType | str, **txn_kwargs):
"""
Have the account class override the value of its ``delegate``. For plugins that support
this feature, the way they choose to handle it can vary. For example, it could be a call to
Expand Down Expand Up @@ -526,9 +526,9 @@ def remove_delegate(self, **txn_kwargs):
@contextmanager
def delegate_to(
self,
new_delegate: Union[BaseAddress, AddressType, str],
set_txn_kwargs: Optional[dict] = None,
reset_txn_kwargs: Optional[dict] = None,
new_delegate: BaseAddress | AddressType | str,
set_txn_kwargs: dict | None = None,
reset_txn_kwargs: dict | None = None,
**txn_kwargs,
) -> Iterator[BaseAddress]:
"""
Expand Down Expand Up @@ -799,7 +799,7 @@ def get_test_account(self, index: int) -> "TestAccountAPI": # type: ignore[empt
"""

@abstractmethod
def generate_account(self, index: Optional[int] = None) -> "TestAccountAPI":
def generate_account(self, index: int | None = None) -> "TestAccountAPI":
"""
Generate a new test account.
"""
Expand Down Expand Up @@ -832,10 +832,10 @@ class ImpersonatedAccount(AccountAPI):
def address(self) -> AddressType:
return self.raw_address

def sign_message(self, msg: Any, **signer_options) -> Optional[MessageSignature]:
def sign_message(self, msg: Any, **signer_options) -> MessageSignature | None:
raise APINotImplementedError("This account cannot sign messages")

def sign_transaction(self, txn: TransactionAPI, **signer_options) -> Optional[TransactionAPI]:
def sign_transaction(self, txn: TransactionAPI, **signer_options) -> TransactionAPI | None:
# Returns input transaction unsigned (since it doesn't have access to the key)
return txn

Expand Down
4 changes: 2 additions & 2 deletions src/ape/api/address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import abstractmethod
from functools import cached_property
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any

from ape.exceptions import AccountsError, ConversionError
from ape.types.address import AddressType
Expand Down Expand Up @@ -179,7 +179,7 @@ def is_contract(self) -> bool:
return self.codesize > 0

@property
def delegate(self) -> Optional["BaseAddress"]:
def delegate(self) -> "BaseAddress | None":
"""
Check and see if Account has a "delegate" contract, which is a contract that this account
delegates functionality to. This could be from many contexts, such as a Smart Wallet like
Expand Down
36 changes: 18 additions & 18 deletions src/ape/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections.abc import Iterable, Iterator
from functools import cached_property
from pathlib import Path
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING

from ape.exceptions import APINotImplementedError, ContractLogicError
from ape.utils.basemodel import BaseInterfaceModel
Expand Down Expand Up @@ -44,12 +44,12 @@ def name(self) -> str:
The name of the compiler.
"""

def get_config(self, project: Optional["ProjectManager"] = None) -> "PluginConfig":
def get_config(self, project: "ProjectManager | None" = None) -> "PluginConfig":
"""
The combination of settings from ``ape-config.yaml`` and ``.compiler_settings``.

Args:
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.

Expand Down Expand Up @@ -77,7 +77,7 @@ def get_versions(self, all_paths: Iterable[Path]) -> set[str]: # type: ignore[e
def get_compiler_settings( # type: ignore[empty-body]
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"] = None,
project: "ProjectManager | None" = None,
**overrides,
) -> dict["Version", dict]:
"""
Expand All @@ -86,7 +86,7 @@ def get_compiler_settings( # type: ignore[empty-body]

Args:
contract_filepaths (Iterable[pathlib.Path]): The list of paths.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.
**overrides: Settings overrides.
Expand All @@ -99,18 +99,18 @@ def get_compiler_settings( # type: ignore[empty-body]
def compile(
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"],
settings: Optional[dict] = None,
project: "ProjectManager | None",
settings: dict | None = None,
) -> Iterator["ContractType"]:
"""
Compile the given source files. All compiler plugins must implement this function.

Args:
contract_filepaths (Iterable[pathlib.Path]): A list of source file paths to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.
settings (Optional[dict]): Adhoc compiler settings.
settings (dict | None): Adhoc compiler settings.

Returns:
list[:class:`~ape.type.contract.ContractType`]
Expand All @@ -120,16 +120,16 @@ def compile(
def compile_code( # type: ignore[empty-body]
self,
code: str,
project: Optional["ProjectManager"],
settings: Optional[dict] = None,
project: "ProjectManager | None",
settings: dict | None = None,
**kwargs,
) -> "ContractType":
"""
Compile a program.

Args:
code (str): The code to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.
settings (Optional[Dict]): Adhoc compiler settings.
Expand All @@ -141,15 +141,15 @@ def compile_code( # type: ignore[empty-body]

@raises_not_implemented
def get_imports( # type: ignore[empty-body]
self, contract_filepaths: Iterable[Path], project: Optional["ProjectManager"]
self, contract_filepaths: Iterable[Path], project: "ProjectManager | None"
) -> dict[str, list[str]]:
"""
Returns a list of imports as source_ids for each contract's source_id in a given
compiler.

Args:
contract_filepaths (Iterable[pathlib.Path]): A list of source file paths to compile.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.

Expand All @@ -161,15 +161,15 @@ def get_imports( # type: ignore[empty-body]
def get_version_map( # type: ignore[empty-body]
self,
contract_filepaths: Iterable[Path],
project: Optional["ProjectManager"] = None,
project: "ProjectManager | None" = None,
) -> dict["Version", set[Path]]:
"""
Get a map of versions to source paths.

Args:
contract_filepaths (Iterable[Path]): Input source paths. Defaults to all source paths
per compiler.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.

Expand Down Expand Up @@ -238,7 +238,7 @@ def trace_source( # type: ignore[empty-body]

@raises_not_implemented
def flatten_contract( # type: ignore[empty-body]
self, path: Path, project: Optional["ProjectManager"] = None, **kwargs
self, path: Path, project: "ProjectManager | None" = None, **kwargs
) -> "Content":
"""
Get the content of a flattened contract via its source path.
Expand All @@ -247,7 +247,7 @@ def flatten_contract( # type: ignore[empty-body]

Args:
path (``pathlib.Path``): The source path of the contract.
project (Optional[:class:`~ape.managers.project.ProjectManager`]): Optionally provide
project ("ProjectManager | None"): Optionally provide
the project containing the base paths and full source set. Defaults to the local
project. Dependencies will change this value to their respective projects.
**kwargs (Any): Additional compiler-specific settings. See specific
Expand Down
Loading
Loading