gurudesh/pytracebugs huggingface dataset:
# Buggy code
def __init__(self, o):
    """
    Initialize the artist inspector with an
    :class:`~matplotlib.artist.Artist` or sequence of :class:`Artists`.
    If a sequence is used, we assume it is a homogeneous sequence (all
    :class:`Artists` are of the same type) and it is your responsibility
    to make sure this is so.
    """
    if cbook.iterable(o) and len(o):
        o = o[0]

    self.oorig = o
    if not isinstance(o, type):
        o = type(o)
    self.o = o

    self.aliasd = self.get_aliases()


# Traceback (TypeError)
import matplotlib.pyplot as plt
import itertools
lines1 = plt.plot(range(3), range(3), range(5), range(5))
lines2 = plt.plot(range(4), range(4), range(6), range(6))
plt.setp(itertools.chain(lines1, lines2), color='red')
Traceback (most recent call last):

File "<ipython-input-6-2f274dd0d4c1>", line 1, in <module>
plt.setp(itertools.chain(lines1, lines2), color='red')

File "/home/jfoxrabi/miniconda3/lib/python3.5/site-packages/matplotlib/pyplot.py", line 351, in setp
return _setp(*args, **kwargs)

File "/home/jfoxrabi/miniconda3/lib/python3.5/site-packages/matplotlib/artist.py", line 1437, in setp
insp = ArtistInspector(obj)

File "/home/jfoxrabi/miniconda3/lib/python3.5/site-packages/matplotlib/artist.py", line 1032, in __init__
if cbook.iterable(o) and len(o):

TypeError: object of type 'itertools.chain' has no len()

# Fixed code
def __init__(self, o):
    """
    Initialize the artist inspector with an
    :class:`~matplotlib.artist.Artist` or iterable of :class:`Artists`.
    If an iterable is used, we assume it is a homogeneous sequence (all
    :class:`Artists` are of the same type) and it is your responsibility
    to make sure this is so.
    """
    if cbook.iterable(o):
        # Wrapped in list instead of doing try-except around next(iter(o))
        o = list(o)
        if len(o):
            o = o[0]

    self.oorig = o
    if not inspect.isclass(o):
        o = type(o)
    self.o = o

    self.aliasd = self.get_aliases()
# Buggy code
def remove(self):
    for c in self:
        c.remove()

    if self._remove_method:
        self._remove_method(self)


# Traceback (TypeError)
In [7]: c = ax.stem([1,2],[2,1])

In [8]: c.remove()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-dbc7beefa92d> in <module>()
----> 1 c.remove()

python2.7/site-packages/matplotlib/container.pyc in remove(self)
33     def remove(self):
34         for c in self:
---> 35             c.remove()
36
37         if self._remove_method:

TypeError: remove() takes exactly one argument (0 given)

# Fixed code
def remove(self):
    for c in cbook.flatten(self, scalarp=lambda x: isinstance(x, martist.Artist)):
        c.remove()

    if self._remove_method:
        self._remove_method(self)
# Buggy code
def make_image(self, magnification=1.0):
    if self._A is None:
        raise RuntimeError("You must first set the image array")
    fc = self.axes.patch.get_facecolor()
    bg = mcolors.colorConverter.to_rgba(fc, 0)
    bg = (np.array(bg) * 255).astype(np.uint8)
    l, b, r, t = self.axes.bbox.extents
    width = (round(r) + 0.5) - (round(l) - 0.5)
    height = (round(t) + 0.5) - (round(b) - 0.5)
    width = width * magnification
    height = height * magnification
    if self._rgbacache is None:
        A = self.to_rgba(self._A, bytes=True)
        self._rgbacache = A
        if self._A.ndim == 2:
            self.is_grayscale = self.cmap.is_gray()
    else:
        A = self._rgbacache
    vl = self.axes.viewLim
    im = _image.pcolor2(
        self._Ax, self._Ay, A, height, width, (vl.x0, vl.x1, vl.y0, vl.y1), bg
    )
    im.is_grayscale = self.is_grayscale
    return im


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 341, in resizeEvent
self.draw()
File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 143, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 475, in draw
self.figure.draw(self.renderer)
File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 60, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/matplotlib/figure.py", line 1094, in draw
func(*args)
File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 60, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2096, in draw
a.draw(renderer)
File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 60, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/matplotlib/image.py", line 881, in draw
im = self.make_image(renderer.get_image_magnification())
File "/usr/lib/python2.7/site-packages/matplotlib/image.py", line 869, in make_image
bg)
TypeError: integer argument expected, got float

# Fixed code
def make_image(self, magnification=1.0):
    if self._A is None:
        raise RuntimeError("You must first set the image array")
    fc = self.axes.patch.get_facecolor()
    bg = mcolors.colorConverter.to_rgba(fc, 0)
    bg = (np.array(bg) * 255).astype(np.uint8)
    l, b, r, t = self.axes.bbox.extents
    width = (round(r) + 0.5) - (round(l) - 0.5)
    height = (round(t) + 0.5) - (round(b) - 0.5)
    # The extra cast-to-int is only needed for python2
    width = int(round(width * magnification))
    height = int(round(height * magnification))
    if self._rgbacache is None:
        A = self.to_rgba(self._A, bytes=True)
        self._rgbacache = A
        if self._A.ndim == 2:
            self.is_grayscale = self.cmap.is_gray()
    else:
        A = self._rgbacache
    vl = self.axes.viewLim
    im = _image.pcolor2(
        self._Ax, self._Ay, A, height, width, (vl.x0, vl.x1, vl.y0, vl.y1), bg
    )
    im.is_grayscale = self.is_grayscale
    return im
# Buggy code
def _init(self):
    """
    Initialization delayed until first draw;
    allow time for axes setup.
    """
    # It seems that there are not enough event notifications
    # available to have this work on an as-needed basis at present.
    if True:  # not self._initialized:
        trans = self._set_transform()
        ax = self.ax
        sx, sy = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height))
        self.span = sx
        if self.width is None:
            sn = max(8, min(25, math.sqrt(self.N)))
            self.width = 0.06 * self.span / sn


# Traceback (TypeError)
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1437, in __call__
return self.func(*args)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 236, in resize
self.show()
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 239, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 421, in draw
self.figure.draw(self.renderer)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 898, in draw
func(*args)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 1997, in draw
a.draw(renderer)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/quiver.py", line 304, in draw
self._init()
File "/usr/lib/pymodules/python2.7/matplotlib/quiver.py", line 272, in _init
np.zeros((1,)))
File "/usr/lib/pymodules/python2.7/matplotlib/quiver.py", line 571, in _make_verts
length = a * (widthu_per_lenu / (self.scale * self.width))
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

# Fixed code
def _init(self):
    """
    Initialization delayed until first draw;
    allow time for axes setup.
    """
    # It seems that there are not enough event notifications
    # available to have this work on an as-needed basis at present.
    if True:  # not self._initialized:
        trans = self._set_transform()
        ax = self.ax
        sx, sy = trans.inverted().transform_point((ax.bbox.width, ax.bbox.height))
        self.span = sx
        if self.width is None:
            sn = max(8, min(25, math.sqrt(self.N)))
            self.width = 0.06 * self.span / sn

        # _make_verts sets self.scale if not already specified
        if not self._initialized and self.scale is None:
            self._make_verts(self.U, self.V)

        self._initialized = True
# Buggy code
def text(self, x, y, s, *args, **kwargs):
    """
    Add text to figure.

    Call signature::

      text(x, y, s, fontdict=None, **kwargs)

    Add text to figure at location *x*, *y* (relative 0-1
    coords). See :func:`~matplotlib.pyplot.text` for the meaning
    of the other arguments.

    kwargs control the :class:`~matplotlib.text.Text` properties:

    %(Text)s
    """

    override = _process_text_args({}, *args, **kwargs)
    t = Text(x=x, y=y, text=s)

    t.update(override)
    self._set_artist_props(t)
    self.texts.append(t)
    return t


# Traceback (NotImplementedError)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
caption.remove()
File "C:\Programme\Python27\lib\site-packages\matplotlib\artist.py",
line 134, in remove
raise NotImplementedError('cannot remove artist')
NotImplementedError: cannot remove artist

# Fixed code
def text(self, x, y, s, *args, **kwargs):
    """
    Add text to figure.

    Call signature::

      text(x, y, s, fontdict=None, **kwargs)

    Add text to figure at location *x*, *y* (relative 0-1
    coords). See :func:`~matplotlib.pyplot.text` for the meaning
    of the other arguments.

    kwargs control the :class:`~matplotlib.text.Text` properties:

    %(Text)s
    """

    override = _process_text_args({}, *args, **kwargs)
    t = Text(x=x, y=y, text=s)

    t.update(override)
    self._set_artist_props(t)
    self.texts.append(t)
    t._remove_method = lambda h: self.texts.remove(h)
    return t
# Buggy code
def find_f_previous_method(self, base, top):
    """
    Find the previous method based on base method
    before top method.

    This will append the method into self.pre_method0
    :param base:
    :param top:
    :return: None
    """

    method_set = self.upperFunc(base[0], base[1])

    if method_set is not None:
        if top in method_set:
            self.pre_method0.append(base)
        else:
            for item in method_set:
                self.find_f_previous_method(item, top)


# Traceback (RecursionError)
Traceback (most recent call last):
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
[Previous line repeated 989 more times]
File "main.py", line 164, in find_f_previous_method
method_set = self.upperFunc(base[0], base[1])
File "main.py", line 89, in upperFunc
method_set = self.find_method(class_name, method_name)
File "main.py", line 72, in find_method
if len(list(result)) > 0:
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/analysis/analysis.py", line 1776, in find_methods
classname = bytes(mutf8.MUTF8String.from_str(classname))
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 102, in from_str
c = cls(encode(s))
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in encode
ord_array = [i for i in map(lambda x: ord(x), s)]
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in <listcomp>
ord_array = [i for i in map(lambda x: ord(x), s)]
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in <lambda>
ord_array = [i for i in map(lambda x: ord(x), s)]
RecursionError: maximum recursion depth exceeded while calling a Python object

# Fixed code
def find_f_previous_method(self, base, top):
    """
    Find the previous method based on base method
    before top method.

    This will append the method into self.pre_method0
    :param base:
    :param top:
    :return: None
    """

    method_set = self.upperFunc(base[0], base[1])

    if method_set is not None:
        if top in method_set:
            self.pre_method0.append(base)
        else:
            for item in method_set:
                # prevent some functions from looking for themselves.
                if item == base:
                    continue
                self.find_f_previous_method(item, top)
# Buggy code
def find_s_previous_method(self, base, top):
    """
    Find the previous method based on base method
    before top method.

    This will append the method into self.pre_method1
    :param base:
    :param top:
    :return: None
    """

    method_set = self.upperFunc(base[0], base[1])

    if method_set is not None:
        if top in method_set:
            self.pre_method1.append(base)
        else:
            for item in method_set:
                self.find_s_previous_method(item, top)


# Traceback (RecursionError)
Traceback (most recent call last):
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
File "main.py", line 172, in find_f_previous_method
self.find_f_previous_method(item, top)
[Previous line repeated 989 more times]
File "main.py", line 164, in find_f_previous_method
method_set = self.upperFunc(base[0], base[1])
File "main.py", line 89, in upperFunc
method_set = self.find_method(class_name, method_name)
File "main.py", line 72, in find_method
if len(list(result)) > 0:
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/analysis/analysis.py", line 1776, in find_methods
classname = bytes(mutf8.MUTF8String.from_str(classname))
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 102, in from_str
c = cls(encode(s))
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in encode
ord_array = [i for i in map(lambda x: ord(x), s)]
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in <listcomp>
ord_array = [i for i in map(lambda x: ord(x), s)]
File "/Users/nick/.local/share/virtualenvs/quark-engine-PkXmWEj6/src/androguard/androguard/core/mutf8.py", line 64, in <lambda>
ord_array = [i for i in map(lambda x: ord(x), s)]
RecursionError: maximum recursion depth exceeded while calling a Python object

# Fixed code
def find_s_previous_method(self, base, top):
    """
    Find the previous method based on base method
    before top method.

    This will append the method into self.pre_method1
    :param base:
    :param top:
    :return: None
    """

    method_set = self.upperFunc(base[0], base[1])

    if method_set is not None:
        if top in method_set:
            self.pre_method1.append(base)
        else:
            for item in method_set:
                # prevent some functions from looking for themselves.
                if item == base:
                    continue
                self.find_s_previous_method(item, top)
# Buggy code
def compare(self, action: int, checksum: bytes) -> bool:
    if self.action != action or self.checksum != checksum:
        return False
    if utime.ticks_ms() >= self.deadline:
        if self.workflow is not None:
            loop.close(self.workflow)
        return False
    return True


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 329, in handle_reports
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 468, in dispatch_cmd
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 541, in msg_register
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 363, in setup
AttributeError: 'module' object has no attribute 'workflows'

# Fixed code
def compare(self, action: int, checksum: bytes) -> bool:
    if self.action != action or self.checksum != checksum:
        return False
    if utime.ticks_ms() >= self.deadline:
        if self.workflow is not None:
            # We crossed the deadline, kill the running confirmation
            # workflow. `self.workflow` is reset in the finally
            # handler in `confirm_workflow`.
            loop.close(self.workflow)
        return False
    return True
# Buggy code
def setup(self, action: int, checksum: bytes, app_id: bytes) -> bool:
    if workflow.workflows:
        return False

    self.action = action
    self.checksum = checksum
    self.app_id = app_id

    self.confirmed = None
    self.workflow = self.confirm_workflow()
    loop.schedule(self.workflow)
    return True


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 329, in handle_reports
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 468, in dispatch_cmd
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 541, in msg_register
File "/home/andrew/firmware/core/src/apps/webauthn/__init__.py", line 363, in setup
AttributeError: 'module' object has no attribute 'workflows'

# Fixed code
def setup(self, action: int, checksum: bytes, app_id: bytes) -> bool:
    if workflow.tasks or self.workflow:
        # If any other workflow is running, we bail out.
        return False

    self.action = action
    self.checksum = checksum
    self.app_id = app_id

    self.confirmed = None
    self.workflow = self.confirm_workflow()
    loop.schedule(self.workflow)
    return True
# Buggy code
def get(self, request, *args, **kwargs):
    order = request.GET.get("order", "")
    if not (
        (not order.startswith("-") or order.count("-") == 1)
        and (order.lstrip("-") in self.all_sorts)
    ):
        order = self.get_default_sort_order(request)
    self.order = order

    return super(QueryStringSortMixin, self).get(request, *args, **kwargs)


# Traceback (MySQLdb._exceptions.DataError)
Traceback (most recent call last):
File "/code/site/siteenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/code/site/siteenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/code/site/siteenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/code/site/siteenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/code/site/siteenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.DataError: (1406, "Data too long for column 'code' at row 1")

# Fixed code
def get(self, request, *args, **kwargs):
    self.object = self.get_object()
    return super().get(request, *args, **kwargs)
# Buggy code
def __call__(self, implementation):
    if not iscoroutinefunction(implementation.on_execution):
        raise NonAwaitableDirective("%s is not awaitable" % repr(implementation))

    SchemaRegistry.register_directive(self._schema_name, self)

    self._implementation = implementation
    return implementation


# Traceback (tartiflette.types.exceptions.tartiflette.UnexpectedASTNode)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/src/app/***/__main__.py", line 10, in <module>
sys.exit(run())
File "/usr/src/app/***/app.py", line 425, in run
"utils/sdl-generator/schema.sdl",
File "/usr/src/app/***/engines/tartiflette.py", line 70, in __init__
error_coercer=_error_coercer,
File "/usr/local/lib/python3.7/site-packages/tartiflette/engine.py", line 26, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 76, in transform_ast_to_schema
transformer.transform(raw_ast)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 93, in transform
tree = t.transform(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 107, in transform
subtree.children = list(self._transform_children(subtree.children))
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 44, in _transform_children
yield self._transform_tree(c) if isinstance(c, Tree) else c
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 103, in _transform_tree
return self._call_userfunc(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 37, in _call_userfunc
return f(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 232, in f
return _f(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/transformers/schema_transformer.py", line 389, in input_value_definition
child, child.__class__.__name__
tartiflette.types.exceptions.tartiflette.UnexpectedASTNode: Unexpected AST node `SchemaNode(type='directives', value={'maxLength': {'limit': 512}})`, type `SchemaNode`

# Fixed code
def __call__(self, implementation):
    if not iscoroutinefunction(implementation.on_field_execution):
        raise NonAwaitableDirective("%s is not awaitable" % repr(implementation))

    SchemaRegistry.register_directive(self._schema_name, self)

    self._implementation = implementation
    return implementation
# Buggy code
def _surround_with_execution_directives(func: Callable, directives: list) -> Callable:
    for directive in reversed(directives):
        func = partial(directive["callables"].on_execution, directive["args"], func)
    return func


# Traceback (tartiflette.types.exceptions.tartiflette.UnexpectedASTNode)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/src/app/***/__main__.py", line 10, in <module>
sys.exit(run())
File "/usr/src/app/***/app.py", line 425, in run
"utils/sdl-generator/schema.sdl",
File "/usr/src/app/***/engines/tartiflette.py", line 70, in __init__
error_coercer=_error_coercer,
File "/usr/local/lib/python3.7/site-packages/tartiflette/engine.py", line 26, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 76, in transform_ast_to_schema
transformer.transform(raw_ast)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 93, in transform
tree = t.transform(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 107, in transform
subtree.children = list(self._transform_children(subtree.children))
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 44, in _transform_children
yield self._transform_tree(c) if isinstance(c, Tree) else c
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 103, in _transform_tree
return self._call_userfunc(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 37, in _call_userfunc
return f(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 232, in f
return _f(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/transformers/schema_transformer.py", line 389, in input_value_definition
child, child.__class__.__name__
tartiflette.types.exceptions.tartiflette.UnexpectedASTNode: Unexpected AST node `SchemaNode(type='directives', value={'maxLength': {'limit': 512}})`, type `SchemaNode`

# Fixed code
def _surround_with_execution_directives(func: Callable, directives: list) -> Callable:
    for directive in reversed(directives):
        func = partial(
            directive["callables"].on_field_execution, directive["args"], func
        )
    return func
# Buggy code
def __repr__(self) -> str:
    return "{}(name={!r}, gql_type={!r}, default_value={!r}, description={!r})".format(
        self.__class__.__name__,
        self.name,
        self.gql_type,
        self.default_value,
        self.description,
    )


# Traceback (tartiflette.types.exceptions.tartiflette.UnexpectedASTNode)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/src/app/***/__main__.py", line 10, in <module>
sys.exit(run())
File "/usr/src/app/***/app.py", line 425, in run
"utils/sdl-generator/schema.sdl",
File "/usr/src/app/***/engines/tartiflette.py", line 70, in __init__
error_coercer=_error_coercer,
File "/usr/local/lib/python3.7/site-packages/tartiflette/engine.py", line 26, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 76, in transform_ast_to_schema
transformer.transform(raw_ast)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 93, in transform
tree = t.transform(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 107, in transform
subtree.children = list(self._transform_children(subtree.children))
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 44, in _transform_children
yield self._transform_tree(c) if isinstance(c, Tree) else c
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 103, in _transform_tree
return self._call_userfunc(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 37, in _call_userfunc
return f(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 232, in f
return _f(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/transformers/schema_transformer.py", line 389, in input_value_definition
child, child.__class__.__name__
tartiflette.types.exceptions.tartiflette.UnexpectedASTNode: Unexpected AST node `SchemaNode(type='directives', value={'maxLength': {'limit': 512}})`, type `SchemaNode`

# Fixed code
def __repr__(self) -> str:
    return (
        "{}(name={!r}, gql_type={!r}, "
        "default_value={!r}, description={!r}, directives={!r})".format(
            self.__class__.__name__,
            self.name,
            self.gql_type,
            self.default_value,
            self.description,
            self.directives,
        )
    )
# Buggy code
def __eq__(self, other: Any) -> bool:
    return self is other or (
        type(self) is type(other)
        and self.name == other.name
        and self.gql_type == other.gql_type
        and self.default_value == other.default_value
    )


# Traceback (tartiflette.types.exceptions.tartiflette.UnexpectedASTNode)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/src/app/***/__main__.py", line 10, in <module>
sys.exit(run())
File "/usr/src/app/***/app.py", line 425, in run
"utils/sdl-generator/schema.sdl",
File "/usr/src/app/***/engines/tartiflette.py", line 70, in __init__
error_coercer=_error_coercer,
File "/usr/local/lib/python3.7/site-packages/tartiflette/engine.py", line 26, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 76, in transform_ast_to_schema
transformer.transform(raw_ast)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 93, in transform
tree = t.transform(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 107, in transform
subtree.children = list(self._transform_children(subtree.children))
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 44, in _transform_children
yield self._transform_tree(c) if isinstance(c, Tree) else c
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 103, in _transform_tree
return self._call_userfunc(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 37, in _call_userfunc
return f(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 232, in f
return _f(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/transformers/schema_transformer.py", line 389, in input_value_definition
child, child.__class__.__name__
tartiflette.types.exceptions.tartiflette.UnexpectedASTNode: Unexpected AST node `SchemaNode(type='directives', value={'maxLength': {'limit': 512}})`, type `SchemaNode`

# Fixed code
def __eq__(self, other: Any) -> bool:
    return self is other or (
        type(self) is type(other)
        and self.name == other.name
        and self.gql_type == other.gql_type
        and self.default_value == other.default_value
        and self.directives == other.directives
    )
# Buggy code
def bake(self, schema: "GraphQLSchema") -> None:
    self._schema = schema
    if isinstance(self.gql_type, GraphQLType):
        self._type = self.gql_type
    else:
        self._type["name"] = self.gql_type
        self._type["kind"] = self._schema.find_type(self.gql_type).kind


# Traceback (tartiflette.types.exceptions.tartiflette.UnexpectedASTNode)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/src/app/***/__main__.py", line 10, in <module>
sys.exit(run())
File "/usr/src/app/***/app.py", line 425, in run
"utils/sdl-generator/schema.sdl",
File "/usr/src/app/***/engines/tartiflette.py", line 70, in __init__
error_coercer=_error_coercer,
File "/usr/local/lib/python3.7/site-packages/tartiflette/engine.py", line 26, in __init__
schema_name, custom_default_resolver, exclude_builtins_scalars
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
File "/usr/local/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
build_graphql_schema_from_sdl(sdl, schema=schema)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 76, in transform_ast_to_schema
transformer.transform(raw_ast)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 93, in transform
tree = t.transform(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 107, in transform
subtree.children = list(self._transform_children(subtree.children))
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 44, in _transform_children
yield self._transform_tree(c) if isinstance(c, Tree) else c
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 103, in _transform_tree
return self._call_userfunc(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 37, in _call_userfunc
return f(tree)
File "/usr/local/lib/python3.7/site-packages/lark/visitors.py", line 232, in f
return _f(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tartiflette/sdl/transformers/schema_transformer.py", line 389, in input_value_definition
child, child.__class__.__name__
tartiflette.types.exceptions.tartiflette.UnexpectedASTNode: Unexpected AST node `SchemaNode(type='directives', value={'maxLength': {'limit': 512}})`, type `SchemaNode`

# Fixed code
def bake(self, schema: "GraphQLSchema") -> None:
    self._schema = schema
    self._directives_implementations = get_directive_implem_list(
        self._directives, self._schema
    )
    if isinstance(self.gql_type, GraphQLType):
        self._type = self.gql_type
    else:
        self._type["name"] = self.gql_type
        self._type["kind"] = self._schema.find_type(self.gql_type).kind
# Buggy code
def is_forked(self, owner, repo):  # /repos/:owner/:repo parent
    logging.info("Querying parent info to verify if the repo is forked\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(self, url, r)

    if "fork" in data:
        if "parent" in data:
            return data["parent"]["full_name"]
        return "Parent not available"

    return False


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def is_forked(self, owner, repo):  # /repos/:owner/:repo parent
    logging.info("Querying parent info to verify if the repo is forked\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "fork" in data:
        if "parent" in data:
            return data["parent"]["full_name"]
        return "Parent not available"

    return False
# Buggy code
def is_archived(self, owner, repo):
    logging.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(self, url, r)

    if "archived" in data:
        if data["archived"]:
            if "updated_at" in data:
                return data["updated_at"]
            return "Date not available"
        return False

    return False


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def is_archived(self, owner, repo):
    logging.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "archived" in data:
        if data["archived"]:
            if "updated_at" in data:
                return data["updated_at"]
            return "Date not available"
        return False

    return False
# Buggy code
def __init__(self, config={}):
    worker_type = "repo_info_worker"

    # Define what this worker can be given and know how to interpret
    given = [["github_url"]]
    models = ["repo_info"]

    # Define the tables needed to insert, update, or delete on
    data_tables = ["repo_info"]
    operations_tables = ["worker_history", "worker_job"]

    # Run the general worker initialization
    super().__init__(worker_type, config, given, models, data_tables, operations_tables)

    # Define data collection info
    self.tool_source = "Repo Info Worker"
    self.tool_version = "0.0.1"
    self.data_source = "GitHub API"


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def __init__(self, config={}):
    worker_type = "repo_info_worker"

    # Define what this worker can be given and know how to interpret
    given = [["github_url"]]
    models = ["repo_info"]

    # Define the tables needed to insert, update, or delete on
    data_tables = ["repo_info", "repo"]
    operations_tables = ["worker_history", "worker_job"]

    # Run the general worker initialization
    super().__init__(worker_type, config, given, models, data_tables, operations_tables)

    # Define data collection info
    self.tool_source = "Repo Info Worker"
    self.tool_version = "0.0.1"
    self.data_source = "GitHub API"
# Buggy code
def query_committers_count(self, owner, repo):
    self.logger.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}/contributors?per_page=100"
    committers = 0

    try:
        while True:
            r = requests.get(url, headers=self.headers)
            self.update_gh_rate_limit(r)
            committers += len(r.json())

            if "next" not in r.links:
                break
            else:
                url = r.links["next"]["url"]
    except Exception:
        logging.exception("An error occured while querying contributor count\n")

    return committers


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def query_committers_count(self, owner, repo):
    self.logger.info("Querying committers count\n")
    url = f"https://api.github.com/repos/{owner}/{repo}/contributors?per_page=100"
    committers = 0

    try:
        while True:
            r = requests.get(url, headers=self.headers)
            self.update_gh_rate_limit(r)
            committers += len(r.json())

            if "next" not in r.links:
                break
            else:
                url = r.links["next"]["url"]
    except Exception:
        self.logger.exception("An error occured while querying contributor count\n")

    return committers
# Buggy code
def is_forked(self, owner, repo):  # /repos/:owner/:repo parent
    logging.info("Querying parent info to verify if the repo is forked\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "fork" in data:
        if "parent" in data:
            return data["parent"]["full_name"]
        return "Parent not available"

    return False


# Traceback (TypeError)
INFO:root:Worker ran into an error for task: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}}

INFO:root:Printing traceback...

INFO:root:Traceback (most recent call last):
File "/mnt/md0/github/augur-census/workers/worker_base.py", line 189, in collect
model_method(message, repo_id)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 149, in repo_info_model
forked = self.is_forked(owner, repo)
File "/mnt/md0/github/augur-census/workers/repo_info_worker/repo_info_worker/worker.py", line 232, in is_forked
data = self.get_repo_data(self, url, r)
TypeError: get_repo_data() takes 3 positional arguments but 4 were given

INFO:root:This task inserted 0 tuples before failure.

INFO:root:Notifying broker and logging task failure in database...

INFO:werkzeug:127.0.0.1 - - [31/May/2020 18:48:58] "GET /AUGWOP/heartbeat HTTP/1.1" 200 -
INFO:root:Recorded job error in the history table for: {'job_type': 'MAINTAIN', 'models': ['repo_info'], 'display_name': 'repo_info model for url: https://github.com/davepacheco/node-verror.git', 'given': {'github_url': 'https://github.com/davepacheco/node-verror.git'}, 'worker_id': 'com.augurlabs.core.repo_info_worker.50700'}

INFO:root:Updated job process for model: repo_info

# Fixed code
def is_forked(self, owner, repo):  # /repos/:owner/:repo parent
    self.logger.info("Querying parent info to verify if the repo is forked\n")
    url = f"https://api.github.com/repos/{owner}/{repo}"

    r = requests.get(url, headers=self.headers)
    self.update_gh_rate_limit(r)

    data = self.get_repo_data(url, r)

    if "fork" in data:
        if "parent" in data:
            return data["parent"]["full_name"]
        return "Parent not available"

    return False