Skip to content

Commit

Permalink
chore: run black on all PRs (#127)
Browse files Browse the repository at this point in the history
* chore: run black on all PRs

* chore: `black .`

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
BobTheBuidler and github-actions[bot] authored Nov 10, 2024
1 parent 1ae085b commit 7d37e23
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 13 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/black.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Black Formatter

on:
pull_request:
branches:
- master

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # Check out the PR branch

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Install Black
run: pip install black

- name: Run Black
run: black .

- name: Check for changes
id: changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "changes_detected=false" >> $GITHUB_ENV
fi
- name: Commit changes
if: env.changes_detected == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "chore: \`black .\`"
git push
3 changes: 1 addition & 2 deletions eth_portfolio/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ async def _get_and_yield(

@property
@abstractmethod
def _start_block(self) -> int:
...
def _start_block(self) -> int: ...


_LT = TypeVar("_LT")
Expand Down
3 changes: 1 addition & 2 deletions eth_portfolio/_ydb/token_transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def __repr__(self) -> str:
return f"<{self.__class__.__module__}.{self.__class__.__name__} address={self.address}>"

@abc.abstractproperty
def _topics(self) -> List:
...
def _topics(self) -> List: ...

@a_sync.ASyncIterator.wrap
async def yield_thru_block(self, block) -> AsyncIterator["asyncio.Task[TokenTransfer]"]:
Expand Down
1 change: 0 additions & 1 deletion eth_portfolio/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def __init__(
load_prices: bool = True,
asynchronous: bool = False,
) -> None:

"""
Initialize a Portfolio instance.
Expand Down
3 changes: 1 addition & 2 deletions eth_portfolio/protocols/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async def balances(self, address: Address, block: Optional[Block] = None) -> Tok
return await self._balances(address, block=block)

@abc.abstractmethod
async def _balances(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
...
async def _balances(self, address: Address, block: Optional[Block] = None) -> TokenBalances: ...


class ProtocolWithStakingABC(ProtocolABC, metaclass=abc.ABCMeta):
Expand Down
3 changes: 1 addition & 2 deletions eth_portfolio/protocols/lending/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ async def debt(self, address: Address, block: Optional[Block] = None) -> TokenBa
return await self._debt(address, block) # type: ignore

@abc.abstractmethod
async def _debt(self, address: Address, block: Optional[Block] = None) -> TokenBalances:
...
async def _debt(self, address: Address, block: Optional[Block] = None) -> TokenBalances: ...


class LendingProtocolWithLockedCollateral(LendingProtocol, ProtocolABC):
Expand Down
1 change: 1 addition & 0 deletions tests/_test_completeness.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This is temporarily disabled, might be removed
"""

from typing import Callable

import eth_portfolio.protocols.lending
Expand Down
6 changes: 2 additions & 4 deletions tests/protocols/test_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
SOME_OTHER_TOKEN = "0x0000000000000000000000000000000000000003"


class MockProtocolA(AsyncMock):
...
class MockProtocolA(AsyncMock): ...


class MockProtocolB(AsyncMock):
...
class MockProtocolB(AsyncMock): ...


@patch("a_sync.map")
Expand Down
1 change: 1 addition & 0 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
WALLET_2 = "0x0000000000000000000000000000000000000006"
WALLET_3 = "0x0000000000000000000000000000000000000007"


# Test Balance class
def test_balance_addition():
b1 = Balance(balance=Decimal("10"), usd_value=Decimal("100"))
Expand Down

0 comments on commit 7d37e23

Please sign in to comment.