Skip to content

Commit

Permalink
apply flake8 suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew (from workstation) committed Nov 11, 2020
1 parent 70c090d commit 5271874
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length=140
25 changes: 25 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "flake8"

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements.txt
- name: Analysing the code with flake8
run: |
pylint smart_tv_telegram/
shell: bash
2 changes: 1 addition & 1 deletion smart_tv_telegram/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
]


class Config:
class Config:
_api_id: int
_api_hash: str
_token: str
Expand Down
8 changes: 5 additions & 3 deletions smart_tv_telegram/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def _get_stream_transports(self, local_token: int) -> typing.Set[asyncio.Transpo
return self._stream_trasports[local_token] if local_token in self._stream_trasports else set()

async def _timeout_handler(self, message_id: int, chat_id: int, local_token: int, size: int):
_debounce: typing.Optional[AsyncDebounce] = None # avoid garbage collector

if all(t.is_closing() for t in self._get_stream_transports(local_token)):
blocks = (size // self._config.block_size) + 1

Expand All @@ -120,10 +122,8 @@ async def _timeout_handler(self, message_id: int, chat_id: int, local_token: int
remain_blocks = blocks - len(self._downloaded_blocks[local_token])
del self._downloaded_blocks[local_token]

_debounce = None

if local_token in self._stream_debounce:
_debounce = self._stream_debounce[local_token] # avoid garbage collector
_debounce = self._stream_debounce[local_token]
del self._stream_debounce[local_token]

if local_token in self._stream_trasports:
Expand All @@ -140,6 +140,8 @@ async def _timeout_handler(self, message_id: int, chat_id: int, local_token: int
if local_token in self._stream_debounce:
self._stream_debounce[local_token].reschedule()

del _debounce

async def _stream_handler(self, request: Request) -> typing.Optional[Response]:
_message_id: str = request.match_info["message_id"]

Expand Down

0 comments on commit 5271874

Please sign in to comment.