Skip to content

Commit

Permalink
fix for flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Al Niessner authored and Al Niessner committed Dec 17, 2024
1 parent b53d20e commit 3c46093
Show file tree
Hide file tree
Showing 34 changed files with 105 additions and 146 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/first.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Continuous Integration
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
run-name: ${{ github.actor }} is verifying code for merge compliance
on: [push]
jobs:
Style:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
- name: pylint
run: pylint --rcfile .github/workflows/pylint.rc Python/dawgie
- name: flake8
run: flake8 --ignore E501,W503 Python/dawgie
run: flake8 --ignore E501,E203,W503 Python/dawgie
Security:
name: Code Security
runs-on: ubuntu-24.04
Expand Down
16 changes: 8 additions & 8 deletions Python/dawgie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,13 @@ def collect(self, refs: [(SV_REF, V_REF)]) -> None:
def ds(self) -> 'Dataset':
raise NotImplementedError()

def items(self) -> [(str, {str: {str: 'dagie.Value'}})]:
def items(self) -> [(str, {str: {str: 'dawgie.Value'}})]: # noqa: F821
raise NotImplementedError()

def keys(self) -> [str]:
raise NotImplementedError()

def values(self) -> [{str: {str: 'dawgie.Value'}}]:
def values(self) -> [{str: {str: 'dawgie.Value'}}]: # noqa: F821
raise NotImplementedError()

pass
Expand Down Expand Up @@ -670,13 +670,13 @@ def _algn(self) -> str:
def _bot(self) -> 'Task':
return self.__bot

def _compare_insensitive(self, l, r) -> bool:
def _compare_insensitive(self, left, right) -> bool:
'''Compare two target names ignoring case'''
return l.lower() == r.lower()
return left.lower() == right.lower()

def _compare_sensitive(self, l, r) -> bool:
def _compare_sensitive(self, left, right) -> bool:
'''Compare two target names using case as a discriminator'''
return l == r
return left == right

def _load(self, algref=None, err=True, ver=None) -> None:
'''see load() of this class'''
Expand Down Expand Up @@ -1104,7 +1104,7 @@ def _recede(self, refs: [(SV_REF, V_REF)]) -> None:
def ds(self) -> 'Dataset':
raise NotImplementedError()

def items(self) -> [(str, {str: {str: 'dagie.Value'}})]:
def items(self) -> [(str, {str: {str: 'dawgie.Value'}})]: # noqa: F821
raise NotImplementedError()

def keys(self) -> [str]:
Expand All @@ -1114,7 +1114,7 @@ def recede(self, refs: [(SV_REF, V_REF)]) -> None:
self.ds().measure(self._recede, (refs,))
return

def values(self) -> [{str: {str: 'dawgie.Value'}}]:
def values(self) -> [{str: {str: 'dawgie.Value'}}]: # noqa: F821
raise NotImplementedError()

pass
Expand Down
2 changes: 1 addition & 1 deletion Python/dawgie/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def override(args):
os.path.sep + dawgie.context.ae_base_package.replace('.', os.path.sep)
):
raise ValueError(
f'context-ae-dir ({0}) does not end with context-ae-pkg ({dawgie.context.ae_base_path,dawgie.context.ae_base_package})'
f'context-ae-dir ({0}) does not end with context-ae-pkg ({dawgie.context.ae_base_path}, {dawgie.context.ae_base_package})'
)
return

Expand Down
6 changes: 2 additions & 4 deletions Python/dawgie/db/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
import dawgie.db.util.aspect
import dawgie.util
import dawgie.util.metrics
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import pickle
import psycopg
Expand Down Expand Up @@ -1022,7 +1020,7 @@ def _cur(conn, real_dict=False):
def _fetchone(cur, text):
try:
result = cur.fetchone()[0]
except:
except: # noqa: E722
# error msg should be text so pylint: disable=raise-missing-from
raise RuntimeError(text)
return result
Expand Down
4 changes: 1 addition & 3 deletions Python/dawgie/db/shelve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
import dawgie.db
import dawgie.db.util
import dawgie.util.metrics
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os

from . import util
Expand Down
22 changes: 10 additions & 12 deletions Python/dawgie/db/shelve/comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
import dawgie.db.lockview
import dawgie.context
import dawgie.security
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import pickle
import struct
Expand Down Expand Up @@ -82,11 +80,11 @@ def __do(request):
log.debug('Connector.__do() - sending command')
while len(buf) < 4:
buf += s.recv(4 - len(buf))
l = struct.unpack('>I', buf)[0]
length = struct.unpack('>I', buf)[0]
buf = b''
log.debug('Connector.__do() - receiving command')
while len(buf) < l:
buf += s.recv(l - len(buf))
while len(buf) < length:
buf += s.recv(length - len(buf))
s.close()
return pickle.loads(buf)

Expand Down Expand Up @@ -438,10 +436,10 @@ def acquire(name):
buf = b''
while len(buf) < 4:
buf += s.recv(4 - len(buf))
l = struct.unpack('>I', buf)[0]
length = struct.unpack('>I', buf)[0]
buf = b''
while len(buf) < l:
buf += s.recv(l - len(buf))
while len(buf) < length:
buf += s.recv(length - len(buf))
buf = pickle.loads(buf)
pass
return s
Expand All @@ -454,9 +452,9 @@ def release(s):
buf = b''
while len(buf) < 4:
buf += s.recv(4 - len(buf))
l = struct.unpack('>I', buf)[0]
length = struct.unpack('>I', buf)[0]
buf = b''
while len(buf) < l:
buf += s.recv(l - len(buf))
while len(buf) < length:
buf += s.recv(length - len(buf))
s.close()
return pickle.loads(buf)
4 changes: 1 addition & 3 deletions Python/dawgie/db/shelve/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@

import dawgie.util
import dawgie.util.metrics
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702

from dawgie import Dataset, Timeline
from dawgie.db.util.aspect import Container
Expand Down
2 changes: 1 addition & 1 deletion Python/dawgie/db/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def gather(anz, ans):
raise NotImplementedError()


def metrics() -> '[dawgie.db.METRIC_DATA]':
def metrics() -> '[dawgie.db.METRIC_DATA]': # noqa: F821
raise NotImplementedError()


Expand Down
4 changes: 1 addition & 3 deletions Python/dawgie/db/tools/post2shelve.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@

import argparse
import dawgie.db.shelve.util
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import shelve
import sys
Expand Down
10 changes: 4 additions & 6 deletions Python/dawgie/db/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
'''

import dawgie.context
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import pickle
import shutil
Expand All @@ -49,7 +47,7 @@

def _extract(response):
for pair in filter(
lambda l: 0 < len(l), response.decode('utf-8').split('\n')
lambda s: 0 < len(s), response.decode('utf-8').split('\n')
):
index = pair.find(' ')
cksum = pair[:index]
Expand Down Expand Up @@ -115,7 +113,7 @@ def rotate(path, orig, backup):
t = stack.pop()
for v in backup[t]:
ext = v.split(".")[-1]
shutil.move(v, f'{path}/{t+1:d}.{dawgie.context.db_name}.{ext}')
shutil.move(v, f'{path}/{t+1:d}.{dawgie.context.db_name}.{ext}') # fmt: skip # noqa: E226
for v in orig:
ext = v.split(".")[-1]
shutil.copy(v, f'{path}/0.{dawgie.context.db_name}.{ext}')
Expand All @@ -131,6 +129,6 @@ def verify(value):
result[1] = isinstance(value.bugfix(), int)
result[2] = isinstance(value.design(), int)
result[3] = isinstance(value.implementation(), int)
except:
except: # noqa: E722
pass
return all(result)
6 changes: 2 additions & 4 deletions Python/dawgie/fe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
import enum
import inspect
import json
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import twisted.web.resource
import twisted.web.util
Expand Down Expand Up @@ -307,4 +305,4 @@ def root() -> RoutePoint:


# pylint: disable=ungrouped-imports
import dawgie.fe.app # build all of the dynamic hooks now
import dawgie.fe.app # build all of the dynamic hooks now # noqa: E402
6 changes: 2 additions & 4 deletions Python/dawgie/fe/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
import dawgie.pl.snapshot
import enum
import json
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import pkg_resources
import os
import sys
Expand Down Expand Up @@ -227,7 +225,7 @@ def _search_filter(fn: str, default: {}) -> bytes:
os.path.join(dawgie.context.fe_path, fn), 'rt', encoding="utf-8"
) as f:
default = json.load(f)
except:
except: # noqa: E722
log.exception(
'Text file could not be parsed as JSON'
) # pylint: disable=bare-except
Expand Down
8 changes: 3 additions & 5 deletions Python/dawgie/fe/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
import dawgie.context
import dawgie.tools.submit
import json
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import twisted.internet.reactor
import twisted.web.server
Expand Down Expand Up @@ -110,7 +108,7 @@ def failure(self, fail):
self.__request.write(json.dumps(self.__msg).encode())
try:
self.__request.finish()
except: # pylint: disable=bare-except
except: # pylint: disable=bare-except # noqa: E722
log.exception(
'Failed to complete an error message: %s',
str(self.__msg['alert_message']),
Expand Down Expand Up @@ -222,7 +220,7 @@ def step_5(self, _result):
self.__request.write(json.dumps(result).encode())
try:
self.__request.finish()
except: # pylint: disable=bare-except
except: # pylint: disable=bare-except # noqa: E722
log.exception(
'Failed to complete a successful message: %s', str(result)
)
Expand Down
8 changes: 3 additions & 5 deletions Python/dawgie/fe/svrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
from dawgie.fe import Defer as absDefer

import dawgie
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import twisted.internet.threads


Expand Down Expand Up @@ -81,7 +79,7 @@ def failure(self, result):
)
try:
self.__request.finish()
except:
except: # noqa: E722
log.exception('Failed to complete an error page: %s', str(result))
return

Expand All @@ -90,7 +88,7 @@ def success(self, result):
self.__request.write(self.__display.render().encode())
try:
self.__request.finish()
except:
except: # noqa: E722
log.exception(
'Failed to complete a successful page: %s', str(result)
)
Expand Down
4 changes: 1 addition & 3 deletions Python/dawgie/pl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
NTR:
'''

import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import twisted.internet.defer
import twisted.python.failure

Expand Down
4 changes: 1 addition & 3 deletions Python/dawgie/pl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
import dawgie.tools.submit
import dawgie.util
import logging
import matplotlib

matplotlib.use("Agg")
import matplotlib; matplotlib.use("Agg") # fmt: skip # noqa: E702
import twisted.internet
import sys

Expand Down
4 changes: 1 addition & 3 deletions Python/dawgie/pl/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
import dawgie.util
import dawgie.util.fifo
import enum
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import os
import pydot
import xml.etree.ElementTree
Expand Down
6 changes: 2 additions & 4 deletions Python/dawgie/pl/farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
import dawgie.security
import dawgie.util
import importlib
import logging

log = logging.getLogger(__name__)
import logging; log = logging.getLogger(__name__) # fmt: skip # noqa: E702
import math
import struct
import twisted.internet.task
Expand Down Expand Up @@ -350,7 +348,7 @@ def dispatch():

j.get('do').clear()
_jobs.remove(j)
except:
except: # noqa: E722
log.exception("Error processing from next_job_batch()")
# pylint: enable=bare-except

Expand Down
6 changes: 3 additions & 3 deletions Python/dawgie/pl/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ def receive(s: socket.socket) -> MSG:
buf = b''
while len(buf) < 4:
buf += s.recv(4 - len(buf))
l = struct.unpack('>I', buf)[0]
length = struct.unpack('>I', buf)[0]
buf = b''
while len(buf) < l:
buf += s.recv(l - len(buf))
while len(buf) < length:
buf += s.recv(length - len(buf))
return loads(buf)


Expand Down
Loading

0 comments on commit 3c46093

Please sign in to comment.