Skip to content

Commit

Permalink
pyupgrade goodness
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard committed Oct 7, 2020
1 parent 9a50b5f commit bffec2a
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 46 deletions.
13 changes: 6 additions & 7 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# streamparse documentation build configuration file, created by
# sphinx-quickstart on Sun Jan 19 22:29:52 2014.
Expand Down Expand Up @@ -50,8 +49,8 @@
master_doc = "index"

# General information about the project.
project = u"streamparse"
copyright = u"2014-2017, Parsely"
project = "streamparse"
copyright = "2014-2020, Parsely"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -213,7 +212,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
("index", "streamparse.tex", u"streamparse Documentation", u"Parsely", "manual")
("index", "streamparse.tex", "streamparse Documentation", "Parsely", "manual")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -241,7 +240,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "streamparse", u"streamparse Documentation", [u"Parsely"], 1)]
man_pages = [("index", "streamparse", "streamparse Documentation", ["Parsely"], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -256,8 +255,8 @@
(
"index",
"streamparse",
u"streamparse Documentation",
u"Parsely",
"streamparse Documentation",
"Parsely",
"streamparse",
"Run Python on real-time streams of data.",
"Miscellaneous",
Expand Down
14 changes: 4 additions & 10 deletions examples/kafka-jvm/chef/cookbooks/python/files/default/get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21509,17 +21509,11 @@ def unpack(sources):


if __name__ == "__main__":
if sys.version_info >= (3, 0):
exec("def do_exec(co, loc): exec(co, loc)\n")
import pickle
exec("def do_exec(co, loc): exec(co, loc)\n")
import pickle

sources = sources.encode("ascii") # ensure bytes
sources = pickle.loads(bz2.decompress(base64.decodebytes(sources)))
else:
import cPickle as pickle

exec("def do_exec(co, loc): exec co in loc\n")
sources = pickle.loads(bz2.decompress(base64.decodestring(sources)))
sources = sources.encode("ascii") # ensure bytes
sources = pickle.loads(bz2.decompress(base64.decodebytes(sources)))

try:
temp_dir = unpack(sources)
Expand Down
2 changes: 0 additions & 2 deletions examples/redis/tools/pid_top.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import psutil


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2014-2019 Parsely, Inc.
Copyright 2014-2020 Parsely, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion streamparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
]

__license__ = """
Copyright 2014-2019 Parsely, Inc.
Copyright 2014-2020 Parsely, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion streamparse/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(
raise ValueError("nargs for store_dict actions must be > 0")
if const is not None and nargs != "?":
raise ValueError('nargs must be "?" to supply const')
super(_StoreDictAction, self).__init__(
super().__init__(
option_strings=option_strings,
dest=dest,
nargs=nargs,
Expand Down
2 changes: 1 addition & 1 deletion streamparse/cli/update_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def create_or_update_virtualenvs(
# Check to ensure streamparse is in at least one requirements file
found_streamparse = False
for requirements_path in requirements_paths:
with open(requirements_path, "r") as fp:
with open(requirements_path) as fp:
for line in fp:
if "streamparse" in line:
found_streamparse = True
Expand Down
4 changes: 1 addition & 3 deletions streamparse/cli/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def to_graphviz(topology_class, node_attr=None, edge_attr=None, **kwargs):
for stream_id, grouping in spec.inputs.items():
parent = stream_id.componentId
outputs = all_specs[parent].common.streams[stream_id.streamId].output_fields
label = "Stream: {}\lFields: {}\lGrouping: {}\l".format(
stream_id.streamId, outputs, grouping
)
label = fr"Stream: {stream_id.streamId}\lFields: {outputs}\lGrouping: {grouping}\l"
sametail = f"{parent}-{stream_id.streamId}"
if sametail not in sametail_nodes:
g.node(sametail, shape="point", width="0")
Expand Down
4 changes: 2 additions & 2 deletions streamparse/dsl/bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
config=None,
outputs=None,
):
super(ShellBoltSpec, self).__init__(
super().__init__(
component_cls,
name=name,
inputs=inputs,
Expand All @@ -43,7 +43,7 @@ def __init__(
config=None,
outputs=None,
):
super(JavaBoltSpec, self).__init__(
super().__init__(
component_cls,
name=name,
serialized_java=serialized_java,
Expand Down
4 changes: 2 additions & 2 deletions streamparse/dsl/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __init__(
config=None,
outputs=None,
):
super(JavaComponentSpec, self).__init__(
super().__init__(
component_cls,
name=name,
inputs=inputs,
Expand Down Expand Up @@ -256,7 +256,7 @@ def __init__(
config=None,
outputs=None,
):
super(ShellComponentSpec, self).__init__(
super().__init__(
component_cls,
name=name,
inputs=inputs,
Expand Down
4 changes: 2 additions & 2 deletions streamparse/dsl/spout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(
config=None,
outputs=None,
):
super(ShellSpoutSpec, self).__init__(
super().__init__(
component_cls,
name=name,
par=par,
Expand All @@ -40,7 +40,7 @@ def __init__(
config=None,
outputs=None,
):
super(JavaSpoutSpec, self).__init__(
super().__init__(
component_cls,
name=name,
par=par,
Expand Down
4 changes: 2 additions & 2 deletions streamparse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def ssh_tunnel(env_config, local_port=6627, remote_port=None, quiet=False):
# Periodically check to see if the ssh command failed and returned a
# value, then raise an Exception
if ssh_proc.poll() is not None:
raise IOError(
raise OSError(
f"Unable to open ssh tunnel via: \"{' '.join(ssh_cmd)}\""
)
time.sleep(0.2)
Expand Down Expand Up @@ -212,7 +212,7 @@ def get_topology_definition(topology_name=None, config_file=None):
"--name flags.".format(specs_dir=topology_path)
)
topology_file = topology_files[0]
topology_name = re.sub(r"(^{}|\.py$)".format(topology_path), "", topology_file)
topology_name = re.sub(fr"(^{topology_path}|\.py$)", "", topology_file)
else:
topology_file = f"{os.path.join(topology_path, topology_name)}.py"
if not os.path.exists(topology_file):
Expand Down
4 changes: 1 addition & 3 deletions streamparse/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-

# Copyright 2014-2019 Parsely, Inc.
# Copyright 2014-2020 Parsely, Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 1 addition & 5 deletions test/streamparse/cli/test_run.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import argparse
import unittest
from unittest.mock import patch

from nose.tools import ok_

try:
from unittest.mock import patch
except ImportError:
from mock import patch

from streamparse.cli.run import main, subparser_hook


Expand Down
8 changes: 4 additions & 4 deletions test/streamparse/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class JavaWordCount(Topology):
word_spout = WordSpout.spec(par=2)
word_bolt = JavaBolt.spec(
full_class_name="com.bar.foo.counter.WordCountBolt",
args_list=[u"foo", 1, b"\x09\x10", True, 3.14159],
args_list=["foo", 1, b"\x09\x10", True, 3.14159],
inputs={word_spout: Grouping.fields("word")},
par=8,
outputs=["word", "count"],
Expand All @@ -421,7 +421,7 @@ class JavaWordCount(Topology):
self.assertEqual(
java_object.args_list,
[
JavaObjectArg(string_arg=u"foo"),
JavaObjectArg(string_arg="foo"),
JavaObjectArg(long_arg=1),
JavaObjectArg(binary_arg=b"\x09\x10"),
JavaObjectArg(bool_arg=True),
Expand Down Expand Up @@ -522,7 +522,7 @@ def test_java_spout_valid_arg_list(self):
class JavaWordCount(Topology):
word_spout = JavaSpout.spec(
full_class_name="com.bar.foo.counter.WordSpout",
args_list=[u"foo", 1, b"\x09\x10", True, 3.14159],
args_list=["foo", 1, b"\x09\x10", True, 3.14159],
par=8,
outputs=["word"],
)
Expand All @@ -535,7 +535,7 @@ class JavaWordCount(Topology):
self.assertEqual(
java_object.args_list,
[
JavaObjectArg(string_arg=u"foo"),
JavaObjectArg(string_arg="foo"),
JavaObjectArg(long_arg=1),
JavaObjectArg(binary_arg=b"\x09\x10"),
JavaObjectArg(bool_arg=True),
Expand Down

0 comments on commit bffec2a

Please sign in to comment.