Skip to content

Commit e4a72e7

Browse files
committed
Ruff
1 parent cb58ff2 commit e4a72e7

File tree

9 files changed

+50
-26
lines changed

9 files changed

+50
-26
lines changed

.github/README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@
2222
## Local Development
2323

2424
**Before pushing:**
25-
```bash
26-
./scripts/ruff_check_format_assets.sh
27-
```
25+
```bash
26+
# Setup venv
27+
python3 -m venv venv
28+
source venv/bin/activate
29+
30+
# Install requirements
31+
pip install -r requirements.txt
32+
33+
# Use the custom ruff script for linting (includes SQL formatting and aggressive linting)
34+
./scripts/ruff_check_format_assets.sh
35+
```
2836

2937
**Optional checks:**
3038
```bash

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ jobs:
9797
docker rm test-container
9898
9999
- name: Validate Docker Compose
100-
run: docker-compose config
100+
run: docker compose config

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Suite
1+
name: Tests
22

33
on:
44
pull_request:
@@ -62,7 +62,7 @@ jobs:
6262
pip install pytest
6363
6464
- name: Validate Docker setup
65-
run: docker-compose config > /dev/null
65+
run: docker compose config > /dev/null
6666

6767
- name: Run integration tests
6868
run: |

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data/
1010
postgres_data/
1111
logs/
1212
subgraph/
13-
contracts/
13+
contracts/contract.abi.json
1414

1515
# Ignore Ruff
1616
.ruff_cache/

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,28 @@ For details: [.github/README.md](./.github/README.md)
6565

6666
For contributors working on the codebase:
6767

68-
1. **Run local quality checks**:
68+
**Before pushing:**
6969
```bash
70-
# Use the custom ruff script (includes SQL formatting and aggressive linting)
71-
./scripts/ruff_check_format_assets.sh
70+
# Setup venv
71+
python3 -m venv venv
72+
source venv/bin/activate
7273

73-
# Type checking
74-
mypy src/ --ignore-missing-imports
74+
# Install requirements
75+
pip install -r requirements.txt
7576

76-
# Security scanning
77-
bandit -r src/
77+
# Use the custom ruff script for linting (includes SQL formatting and aggressive linting)
78+
./scripts/ruff_check_format_assets.sh
7879
```
7980

80-
**Note:** The CI/CD pipeline uses the custom `ruff_check_format_assets.sh` script which includes SQL whitespace fixes and more aggressive formatting than standard ruff. Always run this script locally before pushing to avoid CI failures.
81+
**Optional checks:**
82+
```bash
83+
mypy src/ --ignore-missing-imports
84+
bandit -r src/
85+
```
86+
87+
> **Note:** The CI/CD pipeline uses the custom `ruff_check_format_assets.sh` script which includes SQL whitespace fixes and more aggressive formatting than standard ruff.
88+
>
89+
> Always run this script locally before pushing to avoid CI failures.
8190
8291
## License
8392

src/models/bigquery_data_access_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _read_gbq_dataframe(self, query: str) -> DataFrame:
5454
logger.warning(f"GOOGLE_APPLICATION_CREDENTIALS path not found: {creds_path}")
5555
logger.warning("Falling back to gcloud CLI user credentials.")
5656
else:
57-
logger.info(f"Using enviroment variable $GOOGLE_APPLICATION_CREDENTIALS for authentication.")
57+
logger.info("Using enviroment variable $GOOGLE_APPLICATION_CREDENTIALS for authentication.")
5858
else:
5959
logger.warning("GOOGLE_APPLICATION_CREDENTIALS not set, falling back to gcloud CLI user credentials")
6060

src/models/issuance_data_access_helper.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
from pathlib import Path
1212

1313
import pandas as pd
14+
from tenacity import retry, stop_after_attempt, wait_exponential
1415
from web3 import Web3
1516
from web3.contract import Contract
16-
from tenacity import retry, stop_after_attempt, wait_exponential
1717

1818
# Import data providers
1919
from src.models.bigquery_data_access_provider import BigQueryProvider
2020
from src.models.subgraph_data_access_provider import SubgraphProvider
2121

2222
# Import configuration and key validation
2323
from src.utils.config_loader import ConfigLoader, ConfigurationError
24-
from src.utils.key_validator import validate_and_format_private_key, KeyValidationError
24+
from src.utils.key_validator import KeyValidationError, validate_and_format_private_key
2525

2626
logger = logging.getLogger(__name__)
2727

@@ -34,7 +34,7 @@
3434
def _validate_required_fields(data: dict, required_fields: list[str], context: str) -> None:
3535
"""
3636
Helper function to validate required fields are present in a dictionary.
37-
37+
3838
Args:
3939
data: Dictionary to validate
4040
required_fields: List of required fields
@@ -96,7 +96,13 @@ def _load_config_and_return_validated() -> dict[str, str | int | list]:
9696
) from e
9797

9898
# Validate blockchain configuration contains all required fields
99-
required_fields = ["private_key", "contract_address", "contract_function", "chain_id", "scheduled_run_time"]
99+
required_fields = [
100+
"private_key",
101+
"contract_address",
102+
"contract_function",
103+
"chain_id",
104+
"scheduled_run_time",
105+
]
100106
_validate_required_fields(config, required_fields, "Missing required blockchain configuration")
101107

102108
# Validate RPC providers
@@ -133,9 +139,7 @@ def _get_path_to_project_root() -> Path:
133139
current_path = current_path.parent
134140

135141
# If we got here, something is wrong
136-
raise FileNotFoundError(
137-
"Could not find project root directory. Investigate."
138-
)
142+
raise FileNotFoundError("Could not find project root directory. Investigate.")
139143

140144

141145
def _parse_and_validate_credentials_json(creds_env: str) -> dict:
@@ -265,7 +269,7 @@ def _setup_google_credentials_in_memory_from_env_var():
265269
if creds_data is not None:
266270
creds_data.clear()
267271
del creds_data
268-
272+
269273
else:
270274
logger.warning(
271275
"GOOGLE_APPLICATION_CREDENTIALS is not set or not in the correct format. "
@@ -339,7 +343,7 @@ def _clean_old_date_directories(data_output_dir: Path, max_age_before_deletion:
339343
if age_days > max_age_before_deletion:
340344
logger.info(f"Removing old data directory: {item} ({age_days} days old)")
341345
shutil.rmtree(item)
342-
346+
343347
# Skip directories that don't match date format
344348
except ValueError:
345349
continue
@@ -423,7 +427,7 @@ def _setup_transaction_account(private_key: str, w3) -> tuple[str, object]:
423427
account = w3.eth.account.from_key(private_key)
424428
logger.info(f"Using account: {account.address}")
425429
return account.address
426-
430+
427431
# If the account cannot be retrieved, log the error and raise an exception
428432
except Exception as e:
429433
logger.error(f"Failed to retrieve account from private key: {str(e)}")

src/utils/config_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
class ConfigurationError(Exception):
3636
"""Raised when configuration loading fails."""
37+
3738
pass
3839

3940

src/utils/key_validator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
class KeyValidationError(Exception):
1616
"""Raised when key validation fails."""
17+
1718
pass
1819

1920

2021
@dataclass
2122
class KeyValidationResult:
2223
"""Result of private key validation."""
24+
2325
is_valid: bool
2426
formatted_key: Optional[str]
2527
error_message: Optional[str]

0 commit comments

Comments
 (0)