Skip to content

Commit

Permalink
chore: upgrade click (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jul 20, 2023
1 parent a19d32b commit 8a718af
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
name: black
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"hypothesis-jsonschema==0.19.0", # JSON Schema fuzzer extension
],
"lint": [
"black>=23.3.0,<24", # Auto-formatter and linter
"black>=23.7.0,<24", # Auto-formatter and linter
"mypy>=0.991,<2", # Static type analyzer
"types-PyYAML", # Needed due to mypy typeshed
"types-requests", # Needed due to mypy typeshed
Expand Down Expand Up @@ -93,7 +93,7 @@
},
include_package_data=True,
install_requires=[
"click>=8.1.3,<8.1.4",
"click>=8.1.6,<9",
"ijson>=3.1.4,<4",
"importlib-metadata",
"ipython>=8.5.0,<9",
Expand All @@ -119,11 +119,11 @@
"eth-utils>=2.0.0,<3",
"hexbytes>=0.2.3,<1",
"py-geth>=3.13.0,<4",
"web3[tester]>=6.5.0,<7",
"web3[tester]>=6.6.1,<7",
# ** Dependencies maintained by ApeWorX **
"eip712>=0.2.1,<0.3",
"ethpm-types>=0.5.3,<0.6",
"evm-trace>=0.1.0a21",
"evm-trace==0.1.0a21",
],
entry_points={
"console_scripts": ["ape=ape._cli:cli"],
Expand Down
6 changes: 3 additions & 3 deletions src/ape/cli/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click
from eth_utils import is_hex

from ape import accounts
from ape import accounts, project
from ape.api import AccountAPI
from ape.cli.choices import Alias
from ape.cli.paramtype import AllFilePaths
Expand Down Expand Up @@ -55,8 +55,8 @@ def _raise_bad_arg(name):
resolved_contract_paths = set()
for contract_path in contract_paths:
# Adds missing absolute path as well as extension.
resolved_contract_path = ctx.obj.project_manager.lookup_path(contract_path)

pm = project if ctx.obj is None else ctx.obj.project_manager
resolved_contract_path = pm.lookup_path(contract_path)
if not resolved_contract_path:
_raise_bad_arg(contract_path.name)

Expand Down
3 changes: 2 additions & 1 deletion src/ape/cli/paramtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ class AllFilePaths(Path):
or a list containing only the given file.
"""

def convert(
def convert( # type: ignore[override]
self, value: Any, param: Optional["Parameter"], ctx: Optional["Context"]
) -> List[PathLibPath]:
path = super().convert(value, param, ctx)
assert isinstance(path, PathLibPath) # For mypy

# NOTE: Return the path if it does not exist so it can be resolved downstream.
return get_all_files_in_directory(path) if path.is_dir() else [path]
11 changes: 11 additions & 0 deletions tests/functional/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
NetworkBoundCommand,
PromptChoice,
account_option,
contract_file_paths_argument,
get_user_selected_account,
network_option,
verbosity_option,
Expand Down Expand Up @@ -323,3 +324,13 @@ def test_account_prompt_name():
assert option.name == "account"
option = AccountAliasPromptChoice(name="account_z")
assert option.name == "account_z"


def test_contract_file_paths_argument(runner):
@click.command()
@contract_file_paths_argument()
def cmd(file_paths):
pass

result = runner.invoke(cmd, ["path0", "path1"])
assert "Contract 'path0' not found" in result.output

0 comments on commit 8a718af

Please sign in to comment.