<commit_before>from __future__ import absolute_import
from ..utils import walk
from ..scan import Dispatcher
from ..spec.v2_0.objects import (
    Schema,
    Parameter,
    Response,
    PathItem,
    )
import functools
import six

def _out(app, parser, path):
    obj = app.resolve(path, parser=parser, before_return=None)
    r = obj.normalized_ref
    return [r] if r else []

def _schema_out_obj(obj, out=None):
    out = [] if out == None else out

    for o in six.itervalues(obj.properties):
        out = _schema_out_obj(o, out)

    for o in obj.allOf:
        out = _schema_out_obj(o, out)

    if isinstance(obj.additionalProperties, Schema):
        out = _schema_out_obj(obj.additionalProperties, out)

    if obj.items:
        out = _schema_out_obj(obj.items, out)

    r = obj.normalized_ref
    if r:
        out.append(r)

    return out

def _schema_out(app, path):
    obj = app.resolve(path, parser=SchemaContext)
    return [] if obj == None else _schema_out_obj(obj)


class CycleDetector(object):
    """ circular detector """

    class Disp(Dispatcher): pass

    def __init__(self):
        self.cycles = {
            'schema':[],
            'parameter':[],
            'response':[],
            'path_item':[]
        }

    @Disp.register([Schema])
    def _schema(self, path, _, app):
        self.cycles['schema'] = walk(
            path,
            functools.partial(_schema_out, app),
            self.cycles['schema']
        )

    @Disp.register([Parameter])
    def _parameter(self, path, _, app):
         self.cycles['parameter'] = walk(
            path,
            functools.partial(_out, app, Parameter),
            self.cycles['parameter']
        )

    @Disp.register([Response])
    def _response(self, path, _, app):
        self.cycles['response'] = walk(
            path,
            functools.partial(_out, app, Response),
            self.cycles['response']
        )

    @Disp.register([PathItem])
    def _path_item(self, path, _, app):
        self.cycles['path_item'] = walk(
            path,
            functools.partial(_out, app, PathItem),
            self.cycles['path_item']
        )

<commit_msg>Make test pass: all these properties won't have default now<commit_after>from __future__ import absolute_import
from ..utils import walk
from ..scan import Dispatcher
from ..spec.v2_0.objects import (
    Schema,
    Parameter,
    Response,
    PathItem,
    )
import functools
import six

def _out(app, parser, path):
    obj = app.resolve(path, parser=parser, before_return=None)
    r = obj.normalized_ref
    return [r] if r else []

def _schema_out_obj(obj, out=None):
    out = [] if out == None else out

    for o in six.itervalues(obj.properties or {}):
        out = _schema_out_obj(o, out)

    for o in obj.allOf or []:
        out = _schema_out_obj(o, out)

    if isinstance(obj.additionalProperties, Schema):
        out = _schema_out_obj(obj.additionalProperties, out)

    if obj.items:
        out = _schema_out_obj(obj.items, out)

    r = obj.normalized_ref
    if r:
        out.append(r)

    return out

def _schema_out(app, path):
    obj = app.resolve(path, parser=Schema)
    return [] if obj == None else _schema_out_obj(obj)


class CycleDetector(object):
    """ circular detector """

    class Disp(Dispatcher): pass

    def __init__(self):
        self.cycles = {
            'schema':[],
            'parameter':[],
            'response':[],
            'path_item':[]
        }

    @Disp.register([Schema])
    def _schema(self, path, _, app):
        self.cycles['schema'] = walk(
            path,
            functools.partial(_schema_out, app),
            self.cycles['schema']
        )

    @Disp.register([Parameter])
    def _parameter(self, path, _, app):
         self.cycles['parameter'] = walk(
            path,
            functools.partial(_out, app, Parameter),
            self.cycles['parameter']
        )

    @Disp.register([Response])
    def _response(self, path, _, app):
        self.cycles['response'] = walk(
            path,
            functools.partial(_out, app, Response),
            self.cycles['response']
        )

    @Disp.register([PathItem])
    def _path_item(self, path, _, app):
        self.cycles['path_item'] = walk(
            path,
            functools.partial(_out, app, PathItem),
            self.cycles['path_item']
        )


{'fraction_non_alphanumeric': 0.12383337127247894, 'fraction_numerical': 0.0009105394946505805, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6595085', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1345, 'n_words': 315}