Skip to content

Commit

Permalink
Add flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
finlaysawyer committed Jan 10, 2021
1 parent 29b52c1 commit a53569e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 18 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/black.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Install Python dependencies
run: pip install black flake8

- name: Run linters
uses: wearerequired/lint-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
black: true
flake8: true
auto_fix: true
2 changes: 1 addition & 1 deletion cogs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def monitor_uptime(self) -> None:
channel = self.bot.get_channel(get_config("notification_channel"))

for i in get_servers():
if i["type"] is "ping":
if i["type"] == "ping":
if ping(i["address"]) is False:
await self.notify_down(i, channel, "Host unknown")
elif ping(i["address"]) is None:
Expand Down
3 changes: 2 additions & 1 deletion cogs/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ async def ping(self, ctx, address: str, pings: int = 1) -> None:
else:
for i in range(pings):
await ctx.send(
f"Received response from {address} in: {str(int(ping(address, unit='ms')))}ms."
f"Received response from {address} in: "
f"{str(int(ping(address, unit='ms')))}ms."
)
await asyncio.sleep(1)

Expand Down
20 changes: 19 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
[tool.black]
line-length = 88
target-version = ['py37']
include = '\.pyi?$'
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \venv
| _build
| buck-out
| build
| dist
)/
| foo.py
)
'''
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
exclude = .git,__pycache__,venv
4 changes: 2 additions & 2 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

def get_servers() -> Iterable:
"""Reads all specified servers specified in servers.json."""
with open('servers.json') as f:
with open("servers.json") as f:
return json.load(f)


def get_config(item: str) -> Union[str, int]:
"""Retrieves the configuration value specified."""
with open('config.json') as f:
with open("config.json") as f:
return json.load(f)[item]

0 comments on commit a53569e

Please sign in to comment.