Add the appropriate python typing to subject (e.g. Optional, List, ...)

        :param subject: Subject to be decorated
        :param all_are_optional: Force everything to be optional
        :return: Typed subject
18424
def python_cardinality(self, subject: str, all_are_optional: bool = False) -> str:
        
        if self.multiple_elements:
            rval = f"typing.List[{subject}]"
        elif self.one_optional_element:
            rval = subject if subject.startswith("typing.Optional[") else f"typing.Optional[{subject}]"
        elif self.max == 0:
            rval = "type(None)"
        else:
            rval = subject
        if all_are_optional and not self.one_optional_element:
            rval = f"typing.Optional[{rval}]"
        return rval
104391
def set_subject_compatibility_level(self, subject, level):
        
        res = requests.put(
            self._url('/config/{}', subject),
            data=json.dumps({'compatibility': level}),
            headers=HEADERS)
        raise_if_failed(res)
876561
def strict(*types):
    """"""

    def decorate(func):
        @wraps(func)
        def wrapper(self, p):
            func(self, p)
            if not isinstance(p[0], types):
                raise YAMLStrictTypeError(p[0], types, func)

        wrapper.co_firstlineno = func.__code__.co_firstlineno
        return wrapper

    return decorate
183720
def serialize(self, subject, *objects_or_combinators):
        
        ec_s = rdflib.BNode()
        if self.operator is not None:
            if subject is not None:
                yield subject, self.predicate, ec_s
            yield from oc(ec_s)
            yield from self._list.serialize(ec_s, self.operator, *objects_or_combinators)
        else:
            for thing in objects_or_combinators:
                if isinstance(thing, Combinator):
                    object = rdflib.BNode()
                    #anything = list(thing(object))
                    #if anything:
                        #[print(_) for _ in anything]
                    hasType = False
                    for t in thing(object):
                        if t[1] == rdf.type:
                            hasType = True
                        yield t

                    if not hasType:
                        yield object, rdf.type, owl.Class
                else:
                    object = thing

                yield subject, self.predicate, object
864613
public void addTriple(final String subject, final String predicate, final String object) {
        addQuad(subject, predicate, object, "@default");
    }
1239258
def substitute_infinitives_as_subjects(sent_str):
    """"""
    sent_doc = textacy.Doc(sent_str, lang='en_core_web_lg')
    #inf_pattern = r'<PART><VERB>+' # To aux/auxpass* csubj
    inf_pattern = r'<PART><VERB>' # To aux/auxpass* csubj
    infinitives = textacy.extract.pos_regex_matches(sent_doc, inf_pattern)
    inf_subjs = [] # => [[0,1],...]
    for inf in infinitives:
        if inf[0].text.lower() != 'to':
            continue
        if ('csubj' not in [w.dep_ for w in inf] and sent_doc[inf[-1].i + 1].dep_
                != 'csubj'):
            continue
        if inf[-1].tag_ != 'VB':
            continue
        inf_subj = []
        for v in inf:
            inf_subj.append(v.i)
        inf_subjs.append(inf_subj) 
    new_sent_str = sent_str
    unusual_char = '形'
    for inf_subj in inf_subjs:
        start_inf = sent_doc[inf_subj[0]].idx 
        end_inf = sent_doc[inf_subj[-1]].idx + len(sent_doc[inf_subj[-1]])
        inf_len = end_inf - start_inf
        sub = (unusual_char * inf_len)
        new_sent_str = new_sent_str[:start_inf] + sub + new_sent_str[end_inf:]
    new_sent_str = re.sub('形+', '{}', new_sent_str)
    repl = [conjugate(sent_doc[i_s[-1]].text, tense='presentparticiple') for i_s in inf_subjs]
    return new_sent_str.format(*repl)
99090
def subject=(subject)
      validator = EnumAttributeValidator.new('String', ["english/language arts", "math", "science", "social studies", "language", "homeroom/advisory", "interventions/online learning", "technology and engineering", "PE and health", "arts and music", "other"])
      unless validator.valid?(subject)
        fail ArgumentError, "invalid value for 'subject', must be one of #{validator.allowable_values}."
      end
      @subject = subject
    end
689077
def add_restriction(self, subject, predicate, object_):
        
        if type(object_) != rdflib.URIRef:
            object_ = self.check_thing(object_)

        if type(predicate) != rdflib.URIRef:
            predicate = self.check_thing(predicate)

        if type(subject) != infixowl.Class:
            if type(subject) != rdflib.URIRef:
                subject = self.check_thing(subject)
            subject = infixowl.Class(subject, graph=self.g)

        restriction = infixowl.Restriction(predicate, graph=self.g, someValuesFrom=object_)
        subject.subClassOf = [restriction] + [c for c in subject.subClassOf]
629199
def all(self, typ, **kwargs):
        
        return self._load(self._request(typ, params=kwargs))
1031859
def get_objects_for_subject(subject=None,
                            object_category=None,
                            relation=None,
                            **kwargs):
    
    searchresult = search_associations(subject=subject,
                                       fetch_objects=True,
                                       rows=0,
                                       object_category=object_category,
                                       relation=relation,
                                       **kwargs
    )
    objs = searchresult['objects']
    return objs
100055
def _verbs_with_subjects(doc):
    """"""
    # TODO: UNUSED
    verb_subj = []
    for possible_subject in doc:
        if (possible_subject.dep_ == 'nsubj' and possible_subject.head.pos_ ==
                'VERB'):
            verb_subj.append([possible_subject.head, possible_subject])
    return verb_subj
69349
def register_subject_version(self, subject, schema):
        
        data = json.dumps({'schema': json.dumps(schema)})
        res = requests.post(self._url('/subjects/{}/versions', subject), data=data, headers=HEADERS)
        raise_if_failed(res)
        return res.json()['id']
843231
def is_trusted_subject(request):
    """"""
    logging.debug('Active subjects: {}'.format(', '.join(request.all_subjects_set)))
    logging.debug('Trusted subjects: {}'.format(', '.join(get_trusted_subjects())))
    return not request.all_subjects_set.isdisjoint(get_trusted_subjects())
268195
def add_task(self, subject, status, **attrs):
        
        return Tasks(self.requester).create(
            self.project, subject, status,
            user_story=self.id, **attrs
        )
282339
def subjects(self):
        

        subj = [i["subject_id"] for i in self._cache.find()]

        return list(set(subj))
1273911
def _parse_subject(subject):
    '''
    
    '''
    ret = {}
    nids = []
    for nid_name, nid_num in six.iteritems(subject.nid):
        if nid_num in nids:
            continue
        try:
            val = getattr(subject, nid_name)
            if val:
                ret[nid_name] = val
                nids.append(nid_num)
        except TypeError as err:
            log.debug("Missing attribute '%s'. Error: %s", nid_name, err)

    return ret
374823
def set_subject(self, value: Union[Literal, Identifier, str], lang: str= None):
        
        return self.metadata.add(key=DC.subject, value=value, lang=lang)