Skip to content

Commit

Permalink
Fix some pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Oct 25, 2021
1 parent 5d6e733 commit a759f80
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion diofant/printing/dot.py
@@ -1,7 +1,7 @@
from ..core import Basic, Expr


__all__ = 'dotprint'
__all__ = 'dotprint',

default_styles = [(Basic, {'color': 'blue', 'shape': 'ellipse'}),
(Expr, {'color': 'black'})]
Expand Down
3 changes: 1 addition & 2 deletions diofant/tests/core/test_args.py
Expand Up @@ -3,7 +3,6 @@
# NOTE: keep tests sorted by (module, class name) key.

import inspect
import io
import os
import re
import warnings
Expand Down Expand Up @@ -178,7 +177,7 @@ def test_all_classes_are_tested():
if not file.endswith('.py'):
continue

with io.open(os.path.join(root, file), 'r', encoding='utf-8') as f:
with open(os.path.join(root, file), encoding='utf-8') as f:
text = f.read()

submodule = module + '.' + file[:-3]
Expand Down
2 changes: 1 addition & 1 deletion diofant/tests/external/test_autowrap.py
Expand Up @@ -115,7 +115,7 @@ def runtest_autowrap_helpers(language, backend):

for file in os.listdir(tmp):
if file.startswith('wrapped_code_') and file.endswith('.c'):
fil = open(tmp + '/' + file)
fil = open(tmp + '/' + file, encoding='utf-8')
assert fil.read() == ('/******************************************************************************\n'
' *' + ('Code generated with diofant ' + diofant.__version__).center(76) + '*\n'
' * *\n'
Expand Down
4 changes: 2 additions & 2 deletions diofant/tests/external/test_codegen.py
Expand Up @@ -120,7 +120,7 @@

def try_run(commands):
"""Run a series of commands and only return True if all ran fine."""
null = open(os.devnull, 'w')
null = open(os.devnull, 'w', encoding='utf-8')
for command in commands:
retcode = subprocess.call(command, stdout=null, shell=True,
stderr=subprocess.STDOUT)
Expand Down Expand Up @@ -185,7 +185,7 @@ def run_test(label, routines, numerical_tests, language, commands, friendly=True
raise NotImplementedError(
f'FIXME: filename extension unknown for language: {language}')

with open(f_name, 'w') as f:
with open(f_name, 'w', encoding='utf-8') as f:
f.write(
main_template[language] % {'statements': ''.join(test_strings)})

Expand Down
2 changes: 1 addition & 1 deletion diofant/tests/logic/test_dimacs.py
Expand Up @@ -17,7 +17,7 @@
def load_file(location):
"""Loads a boolean expression from a file."""
location = os.path.dirname(__file__) + '/' + location
with open(location) as f:
with open(location, encoding='utf-8') as f:
s = f.read()

return load(s)
Expand Down
2 changes: 1 addition & 1 deletion diofant/tests/solvers/test_diophantine.py
Expand Up @@ -871,7 +871,7 @@ def test_sum_of_squares_powers():
assert list(sum_of_powers(5, 1, 2, True)) == [(0, 5), (1, 4), (2, 3)]
assert list(sum_of_powers(6, 2, 2)) == []
assert list(sum_of_powers(3**5, 3, 1)) == []
assert list(sum_of_powers(3**6, 3, 1)) == [(9,)] and (9**3 == 3**6)
assert list(sum_of_powers(3**6, 3, 1)) == [(9,)]
assert list(sum_of_powers(2**1000, 5, 2)) == []


Expand Down
10 changes: 5 additions & 5 deletions diofant/utilities/autowrap.py
Expand Up @@ -167,7 +167,7 @@ def _prepare_files(self, routine):
return

def _generate_code(self, routine, helpers):
with open(f'{self.module_name}.py', 'w') as f:
with open(f'{self.module_name}.py', 'w', encoding='utf-8') as f:
printed = ', '.join(
[str(res.expr) for res in routine.result_variables])
# convert OutputArguments to return value like f2py
Expand Down Expand Up @@ -239,7 +239,7 @@ def _prepare_files(self, routine):
codefilename = f'{self.filename}.{self.generator.code_extension}'

# pyx
with open(pyxfilename, 'w') as f:
with open(pyxfilename, 'w', encoding='utf-8') as f:
self.dump_pyx([routine], f, self.filename)

# setup.py
Expand All @@ -250,7 +250,7 @@ def _prepare_files(self, routine):
else:
np_import = ''
np_includes = ''
with open('setup.py', 'w') as f:
with open('setup.py', 'w', encoding='utf-8') as f:
f.write(self.setup_template.format(ext_args=', '.join(ext_args),
np_import=np_import,
np_includes=np_includes))
Expand Down Expand Up @@ -651,11 +651,11 @@ def _prepare_files(self, routine):

# C
codefilename = self.module_name + '.c'
with open(codefilename, 'w') as f:
with open(codefilename, 'w', encoding='utf-8') as f:
self.dump_c([routine], f, self.filename)

# setup.py
with open('setup.py', 'w') as f:
with open('setup.py', 'w', encoding='utf-8') as f:
self.dump_setup(f)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion diofant/utilities/codegen.py
Expand Up @@ -663,7 +663,7 @@ def write(self, routines, prefix, to_files=False, header=True, empty=True):
if to_files:
for dump_fn in self.dump_fns:
filename = f'{prefix}.{dump_fn.extension}'
with open(filename, 'w') as f:
with open(filename, 'w', encoding='utf-8') as f:
dump_fn(self, routines, f, prefix, header, empty)
else:
result = []
Expand Down

0 comments on commit a759f80

Please sign in to comment.