sassoftware / python-sasctl

Unguarded next inside generator PTC-W0063
Bug risk
Critical
5 occurrences in this check
Call to next() should be wrapped in try-except
459
460        # Default to predict() method if present
461        if method is None and any(m.name == "predict" for m in package.methods):
462            method = next(x for x in package.methods if x.name == "predict")463
464        # Fall back to score() method if present
465        if method is None and any(m.name == "score" for m in package.methods):
Call to next() should be wrapped in try-except
463
464        # Fall back to score() method if present
465        if method is None and any(m.name == "score" for m in package.methods):
466            method = next(x for x in package.methods if x.name == "score")467
468        # Assume first method is init(), so fall back to next method
469        if method is None and len(package.methods) > 1:
Call to next() should be wrapped in try-except
484
485        # If passing column data into Python as an array, need extra assignment statements to set values
486        if array_input and self.column_names is not None:
487            array = next(filter(lambda v: v.is_array, self.variables))488            var_assignments = [
489                "{}[{}] = {};".format(array.name, i + 1, self.column_names[i])
490                for i in range(min(array.size, len(self.column_names)))
Call to next() should be wrapped in try-except
1702        # Go ahead and add the items that were initially returned.
1703        # Do this by "paging" so iterator remains at the correct spot.
1704        for _ in range(len(obj["items"])):
1705            self.append(next(self._paged_items))1706
1707        # Assume that server has more items available
1708        self._has_more = True
Call to next() should be wrapped in try-except
1627    def __next__(self):
1628        # Get next page of items if we're currently out
1629        if not self._cache:
1630            self._cache = next(self._pager)1631
1632        # Return the next item
1633        if self._cache: