Skip to content

Commit

Permalink
fix: random fixes from last couple PRs (#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored May 1, 2024
1 parent a2b8d8e commit a27b232
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/userguides/clis.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ my_accounts = [accounts.load("me"), accounts.load("me2")]
selected_account = get_user_selected_account(account_type=my_accounts)
```

# Contract File Paths
## Contract File Paths

Does your CLI interact with contract source files?
(Think `ape compile`).
Expand Down
42 changes: 23 additions & 19 deletions docs/userguides/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ You can use already-downloaded projects as dependencies by referencing them as l
dependencies:
- name: MyDependency
local: local/path/to/MyDependency
contracts_folder: src/contracts
```

This is helpful when:
Expand Down Expand Up @@ -206,42 +205,47 @@ ape compile --include-dependencies

The following guidelines are applicable to **ALL** dependency types.

### Custom Contracts Folder
### Config Override

You can set the name of the dependency's contracts folder, e.g.:
To use any extra config item for a dependency, such as configurations for compilers needed during compiling, use the `config_override` setting:

```yaml
dependencies:
- name: DappToolsERC20
github: dapphub/erc20
ref: dappnix
contracts_folder: src
- name: dependency
github: org-name/dependency-project-name
config_override:
solidity:
evm_version: paris
```

### File Exclusions
This is the same as if these values were in an `ape-config.yaml` file in the project directly.

### Custom Contracts Folder

To ignore files from a dependency project, use the `exclude` setting to specify glob patterns:
You can set the name of the dependency's contracts folder using the `config_override` key, e.g.:

```yaml
dependencies:
- name: dependency-project-name
github: org-name/dependency-project-name
exclude:
- package.json # Ignore package.json files.
- mocks/**/* # Ignore all files in the 'mocks' directory
- name: DappToolsERC20
github: dapphub/erc20
ref: dappnix
config_override:
contracts_folder: src
```

### Config Override
### File Exclusions

To use any extra config item for a dependency, such as configurations for compilers needed during compiling, use the `config_override` setting:
To ignore files from a dependency project, use the `exclude` setting in the `config_override:compile` section to specify glob patterns:

```yaml
dependencies:
- name: dependency
- name: dependency-project-name
github: org-name/dependency-project-name
config_override:
solidity:
evm_version: paris
compile:
exclude:
- package.json # Ignore package.json files.
- mocks/**/* # Ignore all files in the 'mocks' directory
```

### Solidity Remappings
Expand Down
2 changes: 2 additions & 0 deletions src/ape/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
DEFAULT_LOCAL_TRANSACTION_ACCEPTANCE_TIMEOUT,
DEFAULT_TRANSACTION_ACCEPTANCE_TIMEOUT,
EMPTY_BYTES32,
SOURCE_EXCLUDE_PATTERNS,
USER_AGENT,
ZERO_ADDRESS,
add_padding_to_strings,
Expand Down Expand Up @@ -110,6 +111,7 @@
"returns_array",
"run_until_complete",
"singledispatchmethod",
"SOURCE_EXCLUDE_PATTERNS",
"spawn",
"stream_response",
"Struct",
Expand Down
13 changes: 13 additions & 0 deletions src/ape/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
DEFAULT_LIVE_NETWORK_BASE_FEE_MULTIPLIER = 1.4
DEFAULT_TRANSACTION_TYPE = 0
DEFAULT_MAX_RETRIES_TX = 20
SOURCE_EXCLUDE_PATTERNS = (
"*package.json",
"*package-lock.json",
"*tsconfig.json",
"*.md",
"*.rst",
"*.txt",
"*.py[a-zA-Z]?",
"*.html",
"*.css",
"*.adoc",
)


_python_version = (
f"{sys.version_info.major}.{sys.version_info.minor}"
Expand Down
20 changes: 4 additions & 16 deletions src/ape_compile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
from pathlib import Path
from typing import List, Optional
from typing import Optional, Set

from pydantic import field_validator, model_validator

from ape import plugins
from ape.api import PluginConfig
from ape.utils.misc import SOURCE_EXCLUDE_PATTERNS

DEFAULT_CACHE_FOLDER_NAME = ".cache" # default relative to contracts/
EXCLUDE_PATTERNS = [
"*package.json",
"*package-lock.json",
"*tsconfig.json",
"*.md",
"*.rst",
"*.txt",
"*.py[a-zA-Z]?",
"*.html",
"*.css",
"*.adoc",
]


class Config(PluginConfig):
Expand All @@ -33,7 +22,7 @@ class Config(PluginConfig):
should configure ``include_dependencies`` to be ``True``.
"""

exclude: List[str] = []
exclude: Set[str] = set()
"""
Source exclusion globs across all file types.
"""
Expand Down Expand Up @@ -91,8 +80,7 @@ def validate_cache_folder(self):
@field_validator("exclude", mode="before")
@classmethod
def validate_exclude(cls, value):
excl = [*(value or []), *EXCLUDE_PATTERNS]
return list(set(excl))
return {*(value or []), *SOURCE_EXCLUDE_PATTERNS}


@plugins.register(plugins.Config)
Expand Down

0 comments on commit a27b232

Please sign in to comment.