Skip to content

Commit

Permalink
add flake8-quotes and fix quoting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Riolku authored and quantum5 committed Sep 6, 2021
1 parent 7d0135d commit efc9f42
Show file tree
Hide file tree
Showing 60 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
python-version: 3.9
- name: Install Black and Flake8
run: |
pip install black==19.3b0 flake8 flake8-future-import flake8-logging-format flake8-import-order
pip install black==19.3b0 flake8 flake8-future-import flake8-logging-format flake8-import-order flake8-quotes
- name: Run Flake8
run: |
black --version
Expand Down
2 changes: 1 addition & 1 deletion dmoj/checkers/identical.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ def check(process_output: bytes, judge_output: bytes, pe_allowed: bool = True, *
feedback = None
if pe_allowed and standard(utf8bytes(judge_output), utf8bytes(process_output)):
# in the event the standard checker would have passed the problem, raise a presentation error
feedback = "Presentation Error, check your whitespace"
feedback = 'Presentation Error, check your whitespace'
return CheckerResult(False, 0, feedback=feedback)
2 changes: 1 addition & 1 deletion dmoj/checkers/linecount.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dmoj.result import CheckerResult
from dmoj.utils.unicode import utf8bytes

verdict = u"\u2717\u2713"
verdict = u'\u2717\u2713'


def check(
Expand Down
4 changes: 2 additions & 2 deletions dmoj/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def run_command(line):
return cmd.execute(line[1:])
except InvalidCommandException as e:
if e.message:
print_ansi("#ansi[%s](red|bold)\n" % e.message)
print_ansi('#ansi[%s](red|bold)\n' % e.message)
print()
return 1
else:
Expand All @@ -129,7 +129,7 @@ def run_command(line):
return run_command(judgeenv.cli_command)
else:
while True:
command = input(ansi_style("#ansi[dmoj](magenta)#ansi[>](green) ")).strip()
command = input(ansi_style('#ansi[dmoj](magenta)#ansi[>](green) ')).strip()
run_command(shlex.split(command))
except (EOFError, KeyboardInterrupt):
print()
Expand Down
2 changes: 1 addition & 1 deletion dmoj/commands/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def execute(self, line):
args = self.arg_parser.parse_args(line)

if args.limit is not None and args.limit <= 0:
raise InvalidCommandException("--limit must be >= 0")
raise InvalidCommandException('--limit must be >= 0')

submissions = self.judge.graded_submissions if not args.limit else self.judge.graded_submissions[: args.limit]

Expand Down
2 changes: 1 addition & 1 deletion dmoj/commands/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def execute(self, line):
ext = ext.upper()
language_id = {'PY': 'PY2', 'CPP': 'CPP11', 'JAVA': 'JAVA8'}.get(ext, ext)
else:
raise InvalidCommandException("no language is selected")
raise InvalidCommandException('no language is selected')
elif language_id not in executors:
raise InvalidCommandException("unknown language '%s'" % language_id)
elif time_limit <= 0:
Expand Down
2 changes: 1 addition & 1 deletion dmoj/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def execute(self, line):
map(lambda x: "'%s'" % x, filter(lambda problem_id: problem_id not in supported_problems, problem_ids))
)
if unknown_problems:
raise InvalidCommandException("unknown problem(s) %s" % unknown_problems)
raise InvalidCommandException('unknown problem(s) %s' % unknown_problems)

tester = ProblemTester()
total_fails = 0
Expand Down
4 changes: 2 additions & 2 deletions dmoj/cptbox/syscalls/generate_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@

with open('../syscalls.pyi', 'w') as interface:
print(
'''\
"""\
from typing import List, Dict
translator: List[List[int]]
by_name: Dict[str, int]
by_id: List[str]
SYSCALL_COUNT: int
''',
""",
file=interface,
)
for name in sorted(names):
Expand Down
2 changes: 1 addition & 1 deletion dmoj/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InternalError(Exception):

class OutputLimitExceeded(Exception):
def __init__(self, stream, limit):
super().__init__("exceeded %d-byte limit on %s stream" % (limit, stream))
super().__init__('exceeded %d-byte limit on %s stream' % (limit, stream))


class InvalidCommandException(Exception):
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/ADA.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ class Executor(GCCExecutor):
name = 'ADA'
command = 'gnatmake'
ext = 'adb'
test_program = '''\
test_program = """\
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line ("echo: Hello, World!");
end Hello;
'''
"""

@classmethod
def get_version_flags(cls, command):
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/BF.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dmoj.error import CompileError
from dmoj.executors.C import Executor as CExecutor

template = b'''\
template = b"""\
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
Expand All @@ -29,7 +29,7 @@
{code}
}
'''
"""

trans = {
ord('>'): b'++p;',
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/C.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Executor(GCCExecutor):
flags = ['-std=c99']
ext = 'c'
name = 'C'
test_program = '''
test_program = """
#include <stdio.h>
int main() {
Expand All @@ -15,4 +15,4 @@ class Executor(GCCExecutor):
putchar(ch);
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/C11.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Executor(GCCExecutor):
command_paths = ['gcc']
ext = 'c'
name = 'C11'
test_program = '''
test_program = """
#include <stdio.h>
int main() {
Expand All @@ -16,4 +16,4 @@ class Executor(GCCExecutor):
putchar(ch);
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/CBL.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class Executor(CompiledExecutor):
command = 'cobc'
address_grace = 131072
compile_output_index = 0
test_program = '''\
test_program = """\
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'echo: Hello, World!'.
STOP RUN.
''' # noqa: W191
""" # noqa: W191

def get_compile_args(self):
return [self.get_command(), '-x', '-free', self._code]
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/COFFEE.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Executor(ScriptExecutor):
'eventfd2',
'statx',
]
test_program = '''\
test_program = """\
process.stdin.on 'readable', () ->
chunk = process.stdin.read()
if chunk != null
process.stdout.write chunk
'''
"""
address_grace = 1048576

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/CPP03.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class Executor(GCCExecutor):
std: Optional[str] = None
ext = 'cpp'
name = 'CPP03'
test_program = '''
test_program = """
#include <iostream>
int main() {
std::cout << std::cin.rdbuf();
return 0;
}
'''
"""

def get_flags(self):
return (['-std=%s' % self.std] if self.std else []) + super().get_flags()
4 changes: 2 additions & 2 deletions dmoj/executors/CPP11.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class Executor(CPPExecutor):
command_paths = ['g++-5', 'g++-4.9', 'g++-4.8', 'g++']
std = 'c++11'
name = 'CPP11'
test_program = '''
test_program = """
#include <iostream>
int main() {
auto input = std::cin.rdbuf();
std::cout << input;
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/CPP14.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Executor(CPPExecutor):
command_paths = ['g++-5', 'g++']
std = 'c++14'
name = 'CPP14'
test_program = '''
test_program = """
#include <iostream>
auto input() {
Expand All @@ -17,4 +17,4 @@ class Executor(CPPExecutor):
std::cout << input();
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/CPP17.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Executor(CPPExecutor):
command_paths = ['g++-7', 'g++']
std = 'c++17'
name = 'CPP17'
test_program = '''
test_program = """
#include <iostream>
int main() {
Expand All @@ -15,4 +15,4 @@ class Executor(CPPExecutor):
std::cout << input;
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/CPP20.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Executor(CPPExecutor):
command_paths = ['g++-11', 'g++']
std = 'c++20'
name = 'CPP20'
test_program = '''
test_program = """
#include <iostream>
int main() {
Expand All @@ -15,4 +15,4 @@ class Executor(CPPExecutor):
std::cout << input;
return 0;
}
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/D.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class Executor(CompiledExecutor):
name = 'D'
address_grace = 32768
command = 'dmd'
test_program = '''\
test_program = """\
import std.stdio;
void main() {
writeln(readln());
}
'''
"""
source_filename_format = 'main.{ext}'

def get_compile_args(self):
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/DART.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Executor(CompiledExecutor):
name = 'DART'
nproc = -1 # Dart uses a really, really large number of threads
command = 'dart'
test_program = '''
test_program = """
void main() {
print("echo: Hello, World!");
}
'''
"""
address_grace = 128 * 1024

syscalls = ['epoll_create', 'epoll_ctl', 'epoll_wait', 'timerfd_settime', 'memfd_create', 'ftruncate']
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/F95.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class Executor(GCCExecutor):
name = 'F95'
command = 'gfortran'
ext = 'f95'
test_program = '''\
test_program = """\
character(100) :: line
read(*,'(A)') line
write(*,'(A)') line
end
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/FORTH.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ class Executor(ScriptExecutor):
name = 'FORTH'
command = 'gforth'
ext = 'fs'
test_program = '''\
test_program = """\
: HELLO ( -- ) ." echo: Hello, World!" CR ;
HELLO
'''
"""
fs = [r'/\.gforth-history$']

def get_cmdline(self, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/GAS32.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Executor(PlatformX86Mixin, GASExecutor):
as_name = 'as_x86'
name = 'GAS32'

test_program = r'''.intel_syntax noprefix
test_program = r""".intel_syntax noprefix
.text
.global _start
Expand Down Expand Up @@ -35,4 +35,4 @@ class Executor(PlatformX86Mixin, GASExecutor):
.bss
buffer:
.skip 4096
''' # noqa: W191
""" # noqa: W191
4 changes: 2 additions & 2 deletions dmoj/executors/GAS64.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Executor(PlatformX64Mixin, GASExecutor):
as_name = 'as_x64'
name = 'GAS64'

test_program = r'''.intel_syntax noprefix
test_program = r""".intel_syntax noprefix
.text
.global _start
Expand Down Expand Up @@ -35,4 +35,4 @@ class Executor(PlatformX64Mixin, GASExecutor):
.bss
buffer:
.skip 4096
''' # noqa: W191
""" # noqa: W191
4 changes: 2 additions & 2 deletions dmoj/executors/GASARM.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Executor(GASExecutor):
crt_pre = env.runtime.crt_pre_arm or ['/usr/lib/arm-linux-gnueabihf/crt1.o', '/usr/lib/arm-linux-gnueabihf/crti.o']
crt_post = env.runtime.crt_post_arm or ['/usr/lib/arm-linux-gnueabihf/crtn.o']
name = 'GASARM'
test_program = r'''
test_program = r"""
.global _start
_start:
mov r7, #4
Expand All @@ -28,4 +28,4 @@ class Executor(GASExecutor):
.data
string:
.ascii "echo: Hello, World!\n"
'''
"""
4 changes: 2 additions & 2 deletions dmoj/executors/GO.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Executor(CompiledExecutor):
command = 'go'
syscalls = ['mincore', 'epoll_create1', 'epoll_ctl', 'epoll_pwait', 'pselect6', 'mlock']
test_name = 'echo'
test_program = '''\
test_program = """\
package main
import "os"
Expand All @@ -33,7 +33,7 @@ class Executor(CompiledExecutor):
bio := bufio.NewReader(os.Stdin)
text, _ := bio.ReadString(0)
fmt.Print(text)
}'''
}"""

def get_compile_env(self):
return {
Expand Down
4 changes: 2 additions & 2 deletions dmoj/executors/GROOVY.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Executor(JavaExecutor):
vm = 'groovy_vm'
security_policy = policy

test_program = '''\
test_program = """\
println System.in.newReader().readLine()
'''
"""

def create_files(self, problem_id, source_code, *args, **kwargs):
super().create_files(problem_id, source_code, *args, **kwargs)
Expand Down
Loading

0 comments on commit efc9f42

Please sign in to comment.