source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
#!/usr/bin/env python3
from enum import IntEnum
class EndpointType(IntEnum):
IN = 1
OUT = 2
BIDIR = IN | OUT
@classmethod
def epaddr(cls, ep_num, ep_dir):
assert ep_dir != cls.BIDIR
return ep_num << 1 | (ep_dir == cls.IN)
@classmethod
def epnum(cls, ep_addr):
ret... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | valentyusb/usbcore/endpoint.py | rjeschmi/valentyusb |
#!/usr/bin/env python3
# BlueKitchen GmbH (c) 2014
# primitive dump for PacketLogger format
# APPLE PacketLogger
# typedef struct {
# uint32_t len;
# uint32_t ts_sec;
# uint32_t ts_usec;
# uint8_t type; // 0xfc for note
# }
import sys
import datetime
packet_types = [ "CMD =>", "EVT <=", "ACL =>", "ACL <="]
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"ans... | 3 | source/component/3rd-party/btstack/raw/tool/dump_pklg.py | liangyongxiang/vsf-all-in-one |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
https://pymotw.com/3/asyncio/synchronization.html
'''
import asyncio
async def worker(condition, n):
print("Worker ", n)
async with condition:
print("worker is waiting ", n)
await condition.wait()
print("Worker %d ending" % n)
async def... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than ... | 3 | python/asyncio/conditions.py | bdastur/notes |
from decisionengine_modules.glideinwms.tests.fixtures import ( # noqa: F401
gwms_module_config,
gwms_module_invalid_config,
gwms_src_dir,
)
from decisionengine_modules.glideinwms.UniversalFrontendParams import UniversalFrontendParams
def test_instantiation(gwms_src_dir, gwms_module_config): # noqa: F811... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding sel... | 3 | src/decisionengine_modules/glideinwms/tests/test_UniversalFrontendParams.py | BrunoCoimbra/decisionengine_modules |
import datetime
import unittest
from zoomus import components, util
import responses
def suite():
"""Define all the tests of the module."""
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ParticipantsV2TestCase))
return suite
class MembersV2TestCase(unittest.TestCase):
def setUp(s... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
... | 3 | tests/zoomus/components/group/test_list_members.py | seantibor/zoomus |
from rest_framework import permissions
class UpdateOwnProfile(permissions.BasePermission):
"""Allow user to edit their own profile"""
def has_object_permission(self, request, view, obj):
"""Check user is trying to edit their own profile"""
if request.method in permissions.SAFE_METHODS:
... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/c... | 3 | profiles_api/permissions.py | oscarperezt1991/profiles-rest-api |
import pytest
import datetime
#from datetime import datetime
from freezerstate.statusupdate import StatusUpdate
@pytest.fixture
def statusobj():
obj = StatusUpdate(True, '8:00,9:30,21:00,26:99')
return obj
def test_update_initialization(statusobj):
assert len(statusobj.notification_times) == 3
def test_... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a ty... | 3 | tests/statusupdate_test.py | jgkelly/FreezerState |
import random
r= random.Random()
def wuerfeln():
return r.randint(1, 6) # Augenzahl zwischen 1 und 6
def muenzwurf():
return r.randint(0,1) # 0 = Kopf, 1 = Zahl
print(wuerfeln())
d = {}
for i in range(10000):
augenzahl = wuerfeln()
if augenzahl in d:
d[augenzahl] += 1
e... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
... | 3 | ___Python/Jonas/Python/p05_random/m01_wuerfeln.py | uvenil/PythonKurs201806 |
from office365api.model.model import Model
class Message(Model):
select = ['From', 'Subject', 'Body', 'ToRecipients', 'DateTimeReceived', 'HasAttachments']
def __init__(self, From, ToRecipients, Subject, Body,
HasAttachments=False, Id=None, DateTimeReceived=None):
self.Id = Id
... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than cl... | 3 | office365api/model/message.py | swimlane/python-office365 |
import uuid
from ace.api.apikey import ApiKey
import pytest
key_value = "5dbc0b66-fcf7-4b98-a0f4-59e523dbba92"
key_name = "test"
key_description = "test description"
key_is_admin = False
@pytest.mark.parametrize(
"key",
[
ApiKey(api_key=key_value, name=key_name, description=key_description, is_admi... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"an... | 3 | tests/ace/api/test_apikey.py | ace-ecosystem/ace2-core |
from . import db
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import UserMixin
from . import login_manager
from datetime import datetime
@login_manager.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
class User(UserMixin, db.Model):
__tab... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than cla... | 3 | app/models.py | Garlinsk/Blog |
from Qt.QtCore import *
from Qt.QtGui import *
from Qt.QtWidgets import *
import findWidget_UIs as ui
class findWidgetClass(QWidget, ui.Ui_findReplace):
searchSignal = Signal(str)
replaceSignal = Signal(list)
replaceAllSignal = Signal(list)
def __init__(self, parent):
super(findWidgetClass, sel... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
}... | 3 | python/pw_multiScriptEditor/widgets/findWidget.py | ZBYVFX/NukeToolSet |
# Copyright 2019 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | spriteworld/configs/cobra/common.py | awesome-archive/spriteworld |
from io import BytesIO
import subprocess
import PIL
from ._util import Protocol
def _icat(args, **kwargs):
return subprocess.run(["kitty", "+kitten", "icat", *args], **kwargs)
class Kitty(Protocol):
supports_transparency = True
@staticmethod
def get_pixel_size():
cp = _icat(["--print-wind... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | lib/mplterm/_kitty.py | anntzer/mplterm |
""" This contains a function to run Mathematica commands from python.
Inspired from http://mathematica.stackexchange.com/questions/4643/how-to-use-mathematica-functions-in-python-programs
"""
__author__ = "marchdf"
import subprocess as sp
def run_mathematica_cmd(cmd):
print("Running Mathematica command: ", c... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | mypython/mypython/run_mathematica.py | marchdf/dotfiles |
"""
Tests for dns api
"""
from __future__ import absolute_import, division, unicode_literals
from twisted.trial.unittest import SynchronousTestCase
from mimic.test.helpers import json_request
from mimic.rest.dns_api import DNSApi
from mimic.test.fixtures import APIMockHelper
class DNSTests(SynchronousTestCase):
... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
}... | 3 | mimic/test/test_dns.py | ksheedlo/mimic |
# Manacher's Algorithm
class Manacher():
def __init__(self, s: str) -> None:
self.s = s
def coustruct(self) -> list:
i, j = 0, 0
res = [0] * len(self.s)
while i < len(self.s):
while i - j >= 0 and i + j < len(self.s) and self.s[i - j] == self.s[i + j]:
j += 1
res[i] = j
k = 1
while i - k >= 0 ... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
... | 3 | Python/string/manacher.py | NatsubiSogan/comp_library |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may ... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
}... | 3 | aliyun-python-sdk-cms/aliyunsdkcms/request/v20190101/DescribeMonitorGroupCategoriesRequest.py | liumihust/aliyun-openapi-python-sdk |
#!/usr/bin/env python
import eventlet
eventlet.monkey_patch(socket=True, select=True, time=True)
import eventlet.wsgi
import socketio
import time
from flask import Flask, render_template
from bridge import Bridge
from conf import conf
sio = socketio.Server()
app = Flask(__name__)
msgs = {}
dbw_enable = False
@sio... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answ... | 3 | ros/src/styx/server.py | cryptSky/CarND-Capstone |
#coding:utf-8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fals... | 3 | paddlehub/common/stats.py | cclauss/PaddleHub |
from tocenv.components.position import Position
class DirectionType:
# Clock-wise numbering
Up = 0
Down = 2
Left = 1
Right = 3
class Direction(object):
def __init__(self):
pass
class Direction(object):
def __init__(self, direction_type):
self.direction = direction_... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true... | 3 | tocenv/components/direction.py | KevinJeon/The-Tragedy-of-the-commons |
import unittest
from monty.fractions import gcd, lcm, gcd_float
class FuncTestCase(unittest.TestCase):
def test_gcd(self):
self.assertEqual(gcd(7, 14, 63), 7)
def test_lcm(self):
self.assertEqual(lcm(2, 3, 4), 12)
def test_gcd_float(self):
vs = [6.2, 12.4, 15.5 + 5e-9]
... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": ... | 3 | tests/test_fractions.py | yuuukuma/monty |
class WirelessSettings(object):
def __init__(self, session):
super(WirelessSettings, self).__init__()
self._session = session
def getNetworkWirelessSettings(self, networkId: str):
"""
**Return the wireless settings for a network**
https://developer.cisco.com/docs/mer... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | meraki/api/wireless_settings.py | fsandberg/dashboard-api-python |
from cradmin_legacy.acemarkdown.widgets import AceMarkdownWidget
class Default(AceMarkdownWidget):
template_name = 'devilry_cradmin/devilry_acemarkdown.django.html'
extra_css_classes = ''
def get_context(self, *args, **kwargs):
context = super(Default, self).get_context(*args, **kwargs)
c... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
}... | 3 | devilry/devilry_cradmin/devilry_acemarkdown.py | devilry/devilry-django |
# Copyright DST Group. Licensed under the MIT license.
from CybORG.Shared import Observation
from .GameAction import GameAction
from CybORG.Emulator.EmulatorCLIManager import EmulatorCLIManager
class GameEcho(GameAction):
def __init__(self, echo_cmd: str):
super().__init__()
self.cmd = echo_cmd... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false... | 3 | CybORG/CybORG/Shared/Actions/GameActions/GameEcho.py | rafvasq/cage-challenge-1 |
# coding=utf-8
from django.conf import settings
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.managers import CurrentSiteManager
from django.utils.encoding import force_text
class CommentQuerySet(models.query.QuerySet):
def active(self):
... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": ... | 3 | content_interactions/managers.py | aaboffill/django-content-interactions |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
The fetcher is the component that talks to external APIs to get and put signals
@see SignalExchangeAPI
"""
import typing as t
from threatexchange.signal_type.pdq import PdqSignal
from threatexchange.signal_type.pdq_ocr import PdqOcrSignal
f... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding ... | 3 | python-threatexchange/threatexchange/fetcher/apis/static_sample.py | dxdc/ThreatExchange |
import datetime
class Cliente:
def __init__(self, nome, sobrenome, cpf):
self.nome = nome
self.sobrenome = sobrenome
self.cpf = cpf
class Conta:
def __init__(self, numero, titular, saldo, limite=1000):
# print("Inicializando uma conta...")
self.numero = numero
... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | caelum-py-14-cap8/conta.py | herculeshssj/python |
"""add initial models
Revision ID: 18b9d421fbde
Revises:
Create Date: 2022-03-19 12:36:16.067795
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "18b9d421fbde"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
... | 3 | alembic/versions/18b9d421fbde_add_initial_models.py | maskducks/garlic-bot |
import discord
import jim.config as config
from jim import registrations
from jim.util import util
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as %s (%s)' % (client.user.name, client.user.id,))
registrations.register_cmds()
registrations.register_patterns()
# @client... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | jim/scripts/bot.py | markzz/jim |
import os
from flask import Flask
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
app.config.from_mapping(
SECRET_KEY='dev',
DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),
)
if test_config is None:
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fal... | 3 | flaskr/__init__.py | wiky-avis/flask_app |
"""
Copyright 2019 Glen Harmon
MNTNER Object Description
https://www.ripe.net/manage-ips-and-asns/db/support/documentation/ripe-database-documentation/rpsl-object-types/4-3-descriptions-of-secondary-objects/4-3-4-description-of-the-mntner-object
"""
from .rpsl import Rpsl
class Maintainer(Rpsl):
def __init__(... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
... | 3 | lib/iana/ripe/objects/mntner.py | sschwetz/network_tech |
from OpenGLCffi.GL import params
@params(api='gl', prms=['mode', 'first', 'count', 'instancecount', 'baseinstance'])
def glDrawArraysInstancedBaseInstance(mode, first, count, instancecount, baseinstance):
pass
@params(api='gl', prms=['mode', 'count', 'type', 'indices', 'instancecount', 'baseinstance'])
def glDrawEle... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file writte... | 3 | OpenGLCffi/GL/EXT/ARB/base_instance.py | cydenix/OpenGLCffi |
from ..utils import Object
class ChatEventAction(Object):
"""
Represents a chat event
No parameters required.
"""
ID = "chatEventAction"
def __init__(self, **kwargs):
pass
@staticmethod
def read(q: dict, *args) -> "ChatEventStickerSetChanged or ChatEventMemberLeft... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
... | 3 | pytglib/api/types/chat_event_action.py | iTeam-co/pytglib |
from .mytypes import Types
def bound(objects):
class Bounds(Types):
def __init__(self):
self.x0=self.y0=float('inf')
self.x1=self.y1=-float('inf')
def point (self,point):
x = point[0]
y = point[1]
if x < self.x0:
self.x0 = ... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": ... | 3 | topojson/bounds.py | EduardoCastanho/topojson.py |
# VXT
# Developed by Christian Visintin
#
# MIT License
# Copyright (c) 2021 Christian Visintin
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitati... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},... | 3 | vxt/audio/volatile_audio.py | veeso/voice-xtractor |
import json
class Alpha:
def __init__(self):
self.a = json.loads('file_A')
self.b = json.loads('file_B')
self.c = None
self.d = None
def foo(self):
json.dumps(self.d)
def bar(self, dummy):
self.c = dummy.x
self.d = dummy.y
self.foo()
clas... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
... | 3 | src/stackoverflow/68402729/main.py | mrdulin/python-codelab |
# -*- coding: utf-8 -*-
#
# Copyright 2018 Bartosz Kryza <bkryza@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
... | 3 | decorest/HEAD.py | druid8/decorest |
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from realtor.models import Realtors, Positions
class Realtor(forms.ModelForm):
name = forms.CharField(required=True, widget=forms.TextInput(attrs={'class': 'form-control validate'}))
ema... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},... | 3 | realtor/forms/staffCreation.py | franklin18ru/Indigo |
data = "cqjxjnds"
import string
import re
lc = string.ascii_lowercase
next = dict(zip(lc[:-1], lc[1:]))
three_seq = ["".join(z) for z in zip(lc[:-2], lc[1:-1], lc[2:])]
def check(pw):
if "i" in pw or "o" in pw or "l" in pw:
return False
three_match = False
for seq in three_seq:
if seq in... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fals... | 3 | 2015/11/solve.py | lamperi/aoc |
# -*- coding: utf-8 -*-
#
# This file is licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in w... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
}... | 3 | src/test/python/testSmvFramework/unicode/modules.py | ninjapapa/SMV2 |
"""Register WS API endpoints for HACS."""
from __future__ import annotations
from homeassistant.components.websocket_api import async_register_command
from homeassistant.core import HomeAssistant
from ..api.acknowledge_critical_repository import acknowledge_critical_repository
from ..api.check_local_path import check... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer"... | 3 | casa.CONFIG/frenck-config/custom_components/hacs/tasks/setup_websocket_api.py | janiversen/ha_config |
from unittest import TestCase
from chibi.file import Chibi_path
from chibi.file.snippets import inflate_dir
class Test_inflate_dir( TestCase ):
def test_inflate_dir_should_inflate_current_dir( self ):
result = inflate_dir( '.' )
expected = Chibi_path.current_dir()
self.assertEqual( resul... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
... | 3 | tests/file/orphan_function/infalte_dir.py | dem4ply/chibi |
import itertools
import numpy as np
from solvers.grid_solver import GridSolver
from solvers.math import interpolate_signal, ls_fit
from solvers.tests.base_test_case import BaseTestCase
from solvers.tests.correction_models import linear_correction
class TestGridSolver(BaseTestCase):
offset_candidates = np.arange... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answ... | 3 | solvers/tests/test_grid_solver.py | omyllymaki/shifting-peaks |
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import unittest
from unittest.mock import Mock, patch
import DWF
class FakeResponse:
def __init__(self):
pass
def raise_for_status(self):
pass
def json(self):
return []
# This method will be used by t... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer":... | 3 | dwf-bot/tests/test_DWFGithub.py | joshbressers/dwf-request |
# 9th percentile.
from collections import Counter
class Solution(object):
def majorityElement(self, nums):
return Counter(nums).most_common()[0][0]
# 26th percentile.
class Solution(object):
def majorityElement(self, nums):
counter = {}
max_count = 0
max_num = None
fo... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
}... | 3 | 169_majority_element.py | dakotaw/leetcode |
from decimal import Decimal as D
from django.utils.translation import gettext_lazy as _
from oscar.core import prices
class BaseSurcharge:
"""
Surcharge interface class
This is the superclass to the classes in surcharges.py. This allows using all
surcharges interchangeably (aka polymorphism).
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"ans... | 3 | src/oscar/apps/checkout/surcharges.py | QueoLda/django-oscar |
# This file is part of datacube-ows, part of the Open Data Cube project.
# See https://opendatacube.org for more information.
#
# Copyright (c) 2017-2021 OWS Contributors
# SPDX-License-Identifier: Apache-2.0
from copy import deepcopy
from typing import Any, MutableMapping
def deepinherit(parent: MutableMapping[str, ... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answe... | 3 | datacube_ows/config_toolkit.py | FlexiGroBots-H2020/datacube-ows |
from discord.ext import commands
import os
# Import and load all files
client = commands.Bot(command_prefix="-")
client.remove_command('help')
@client.command(hidden=True)
@commands.is_owner()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
await ctx.send(f'Loaded: {extension}')
... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (... | 3 | main.py | ronanhansel/juvenile |
from django.core.management.base import BaseCommand, CommandError
import sanity.models as models
import re
import time
import datetime
import os
from django.db.models import Max
class Command(BaseCommand):
help = "Closes the specified poll for voting"
def add_arguments(self, parser):
pass
def h... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
... | 3 | sanity/management/commands/update_index.py | TIBHannover/arxiv_preserver |
def combination(n, r):
"""
:param n: the count of different items
:param r: the number of select
:return: combination
n! / (r! * (n - r)!)
"""
r = min(n - r, r)
result = 1
for i in range(n, n - r, -1):
result *= i
for i in range(1, r + 1):
result //= i
return ... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | lib/python-lib/combination.py | takaaki82/Java-Lessons |
# -*- coding: utf-8 -*-
import traceback
import xlsconfig
import util
from tps import tp0, convention
from base_parser import ConverterInfo, BaseParser
# 利用Excel表头描述,进行导表,不需要转换器
class DirectParser(BaseParser):
def __init__(self, filename, module, sheet_index=0):
super(DirectParser, self).__init__(filename, module,... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than... | 3 | xl2code/parsers/direct_parser.py | youlanhai/ExcelToCode |
from zeep.xsd.types.base import Type
from zeep.xsd.types.collection import UnionType # FIXME
from zeep.xsd.types.simple import AnySimpleType # FIXME
class UnresolvedType(Type):
def __init__(self, qname, schema):
self.qname = qname
assert self.qname.text != "None"
self.schema = schema
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?"... | 3 | src/zeep/xsd/types/unresolved.py | rafamoreira/python-zeep |
from pypy.objspace.std.multimethod import *
from rpython.annotator.annrpython import RPythonAnnotator
class W_Root(object):
pass
class W_Int(W_Root):
pass
class W_Str(W_Root):
pass
str_w = MultiMethodTable(1, root_class=W_Root, argnames_before=['space'])
int_w = MultiMethodTable(1, root_class=W_Root, a... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
... | 3 | pypy/objspace/std/test/test_annmm.py | kantai/passe-pypy-taint-tracking |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.test import TestCase
from django.db import models
from opps.flatpages.models import FlatPage
class FlatPagesFields(TestCase):
def test_show_in_menu(self):
field = FlatPage._meta.get_field_by_name('show_in_menu')[0]
self.assertFalse(field.... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
... | 3 | tests/flatpages/test_models.py | jeanmask/opps |
#!/usr/bin/env python3
#
# Wrapper functions for the permutation feature importance.
#
##################################################### SOURCE START #####################################################
import numpy as np
import matplotlib.pyplot as mpl
import sklearn.inspection
### Calculate permutation impor... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding ... | 3 | rfflearn/explainer/permutation.py | tiskw/random-fourier-features |
def init(id, cfg):
log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, cfg.port, cfg.python_script))
return True
def init_standard(id, env):
log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, env.cfg.port, env.cfg.python_script))
return True
def deinit(... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written... | 3 | pythonmod/doc/examples/example0-1.py | luisdallos/unbound |
from torch import nn
from torch.nn import functional as F
# adapted from Fairseq
class CrossEntropyWithLabelSmoothing(nn.Module):
def __init__(self, ls_eps=0.1, ignore_idx=None, reduce=True, reduction='mean', *args, **kwargs):
super(CrossEntropyWithLabelSmoothing, self).__init__()
self.ls_eps = ls... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fals... | 3 | criterions/cross_entropy.py | alibalapour/HATNet |
import math
def primes(n):
# all even numbers greater than 2 are not prime.
s = [False]*2 + [True]*2 + [False,True]*((n-4)//2) + [False]*(n%2)
i = 3;
limit = n**0.5
while i < limit:
sq = i*i
# get rid of ** and skip even numbers.
s[sq : n : i*2] = [False]*(1+(n-sq)//(i*2))
i += 2
# skip n... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excl... | 3 | 69.py | alanbly/ProjectEuler |
from pytest_bdd import scenarios, when, then, given, parsers
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
# Constants
ADDREMOVEELEMENTSPAGE = 'https://the-internet.herokuapp.com/add_remove_elements/'
TITLE = (By.CSS_SELECTOR, "div h3")
ADD_ELEMENT_BUTTON = (By.CSS_SELEC... | [
{
"point_num": 1,
"id": "any_function_over_40_lines",
"question": "Is any function in this file longer than 40 lines?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": ... | 3 | tests/step_defs/test_addRemoveElementsPage_steps.py | DanielBel20/BDD-Heroku |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#
# @Author: José Sánchez-Gallego (gallegoj@uw.edu)
# @Date: 2018-07-08
# @Filename: vacs.py
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause)
#
# @Last modified by: Brian Cherinka
# @Last modified time: 2018-07-09 17:27:59
import importlib
impor... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?"... | 3 | tests/contrib/test_vacs.py | jvazquez77/marvin |
#!/usr/bin/python
#referencia: http://blog.bitify.co.uk/2013/11/connecting-and-calibrating-hmc5883l.html
import smbus
import time
import math
bus = smbus.SMBus(1)
address = 0x1e
MAG_DECLINATION = -21.9
Fator_de_conversao = -100.3
def read_byte(adr):
return bus.read_byte_data(address, adr)
def read_word(adr):
... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excl... | 3 | hmc5883l.py | ThundeRatz/Python-legacy |
import unittest
from app.models import User
class UserModelTest(unittest.TestCase):
def setUp(self):
self.new_user = User(password = 'banana')
def test_password_setter(self):
self.assertTrue(self.new_user.pass_secure is not None)
def test_no_access_password(self):
with ... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | app/tests/test_user.py | amon-wanyonyi/pitch1 |
class Solution(object):
def countPoints(self, points, queries):
"""
:type points: List[List[int]]
:type queries: List[List[int]]
:rtype: List[int]
"""
num_queries = len(queries)
num_pts = len(points)
res = []
count = 0
# for i in range(... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding... | 3 | scripts/python/1828_queries_on_num_of_pts_inside_circle.py | weirdcoder247/leetcode_solutions |
# used to grab template from screen
import sys
import signal
from arknights.player import Player
from arknights.resource import save_position
import cv2
from arknights.imgops import pil2cv
from .common import Bcolors
def log(s: str):
print(Bcolors.OKGREEN + s + Bcolors.ENDC)
def signal_handler(sig):
log('Ca... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",... | 3 | src/arknights/resource/dev/grab_pos.py | WaterHyacinthInNANHU/ArkOS |
from django.test import TestCase, Client
from django.contrib.auth import get_user_model
from django.urls import reverse
class AdminSiteTests(TestCase):
def setUp(self):
self.client = Client()
self.admin_user = get_user_model().objects.create_superuser(
email='admin@gmail.com',
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": fals... | 3 | app/core/tests/test_admin.py | Saurav-Shrivastav/recipe-app-api |
# -*- coding: utf-8 -*-
"""
@author: Chenglong Chen <c.chenglong@gmail.com>
@brief: utils for os
"""
import os
import time
import shutil
def _gen_signature():
# get pid and current time
pid = int(os.getpid())
now = int(time.time())
# signature
signature = "%d_%d" % (pid, now)
return signatur... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"... | 3 | Code/utils/os_utils.py | EricTsai83/Home_Depot_Product_Search_Relevance |
#!/usr/bin/env python3
"""
Return Kth to Last: Implement an algorithm to find the kth to last element
of a singly linked list.
"""
from singly_linked_list import Node, SinglyLinkedList
# Time complexity: O(n).
# Space complexity: O(1).
def kth_to_last(lst, k):
"""This solution implies that the singly linked ... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docs... | 3 | Problems/2/return_kth_to_last/kth_to_last.py | weezybusy/Cracking-the-Coding-Interview |
import os
def get_java_files(directory):
java_files = []
for root, dirs, files in os.walk(directory):
for f in files:
if f.endswith('.java'):
java_files.append(f)
return java_files
def verify_prefix(prefix, files):
if len(files) == 0:
print(prefix + ' directory does not contain any files!')
exit(-1)... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside... | 3 | src/check_names.py | Mytherin/sqlancer |
import unittest
from decimal import Decimal
from . import read_fixture
from walutomatpy import WalutomatOrder
from walutomatpy import OrderCurrencyPair, OrderCurrencyEnum
from walutomatpy import AccountBalances
class TestWalutomatOrder(unittest.TestCase):
def test_order_parsing(self):
raw_order = read_f... | [
{
"point_num": 1,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer": false
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer... | 3 | tests/test_models.py | b1r3k/walutomatpy |
from sklearn.svm import LinearSVC
import numpy as np
def apply_threshold(data, threshold):
data[np.where(np.abs(data) < threshold)] = 0
def train_one(data, loss, C, verbose, max_iter, threshold, dual, tol):
def _get_features(obj):
# Index samples iff they are required
# Helful in reducing mem... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined insi... | 3 | xclib/classifier/_svm.py | iksteen/pyxclib |
import unittest
from app.models import Pitch
Pitch = Pitch
class PitchTest(unittest.TestCase):
'''
Test Class to test the behaviour of the Pitch class
'''
def setUp(self):
'''
Set up method that will run before every Test
'''
self.new_pitch = Pitch()
def test_i... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true... | 3 | tests/test_pitch.py | uwase-diane/min_pitch |
#!/usr/bin/env python2
import time
import nxt.usbsock
import nxt.locator
class CommunicatorNXT(object):
def __init__(self):
self.remote_inbox = 1
self.local_inbox = 2
self.mac_address = '00:16:53:01:B8:C3'
# self.brick = nxt.usbsock.USBSock(self.mac_address).connect()
self... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true... | 3 | usb_test.py | SicariusNoctis/eagle-eye-tracker |
from rest_framework import generics, permissions, authentication
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.settings import api_settings
from user.serializers import UserSerializer, AuthTokenSerializer
class CreateUserView(generics.CreateAPIView):
"""Create a new user in the s... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
... | 3 | app/user/views.py | dulvinw/recipe-api |
from bs4 import BeautifulSoup
import requests
import ast
def scrap_website(url, filter):
soup = __get_html_content_as_soup(url)
return __extract_data(soup, filter)
def __get_html_content_as_soup(url):
response = requests.get(url)
return BeautifulSoup(response.text, 'lxml')
def __extrac... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docs... | 3 | scraper/services/WebScraper.py | grimmhud/django-scraper |
class TopologicalSorting:
def __init__(self, graph, vertices):
self.graph = graph
self.V = vertices
def addEdge(self, u, v):
self.graph[u].append(v)
def topologicalSortUtil(self, v, visited, stack):
visited[v] = True
for i in self.graph[v]:
if visited[i]... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/... | 3 | meteor_reasoner/graphutil/topological_sort.py | wdimmy/MeTeoR |
from typing import List
from pydantic import validate_arguments
from minisculus.wheel._wheel import Wheel
class WheelChain:
"""Processes indexes using a chain of wheels."""
_wheels: List[Wheel]
def __init__(self, wheels: List[Wheel]):
self._validate_wheels(wheels)
self._wheels = wheels... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/... | 3 | minisculus/wheel/_wheel_chain.py | rvodden/minisculus |
import os
import sys
path = os.getcwd()
package_path = (os.path.abspath(os.path.join(path, os.pardir))).replace('\\', '/')+'/'
sys.path.insert(1, package_path)
from config.config import *
##############################################Scrape-1###################################################
def contains(text , su... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer"... | 3 | scripts/processing_scripts/raw_scrape_processing.py | sai-krishna-msk/KickAssist |
from time import time
from typing import Optional
import re
from tools.timer import getPrevTime
def hex_to_rgb(hex_string):
r_hex = hex_string[1:3]
g_hex = hex_string[3:5]
b_hex = hex_string[5:7]
return int(r_hex, 16), int(g_hex, 16), int(b_hex, 16)
def wheel(pos):
"""Generate rainbow colors acr... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docs... | 3 | python/tools/tools.py | sshcrack/dancyPi-audio-reactive-led |
def enclosing():
str = 'closed over'
def local_func():
print(str)
return local_func
lf = enclosing()
lf()
print(lf.__closure__)
| [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"... | 3 | 02_advance/03_closures_and_decorators/closure.py | bluehenry/python.best.practices |
import spacy
from spacy.lang.en import English
from spacy.util import minibatch, compounding
from spacy.util import decaying
class ExperimentParam:
def __init__(self, TRAIN_DATA: list, max_batch_sizes: dict, model_type='ner',
dropout_start: float = 0.6, dropout_end: float = 0.2, interval: float =... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answ... | 3 | src/textlabelling/experimentparam.py | aakinlalu/textlabelling |
steps = 0
c = {}
m = 1
def collatz(n):
global steps
if n in c:
steps += c[n]
return
if n == 1:
return
steps += 1
if n % 2 == 0:
collatz(n/2)
return
collatz(3 * n + 1)
def main(max):
global steps
global m
for i in range(1, max):... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"ans... | 3 | Python/14 - Longest Collatz sequence/main.py | Dinoosawruss/project-euler |
from functools import wraps
import time
import inspect
from . import helpers
def memoize(ttl_spec, whitelist=None, blacklist=None,
key_fn=helpers._json_keyify, backend=lambda fn: dict(),
get_now=time.time):
""" memoize/cache the decorated function for ttl amount of time """
ttl = hel... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
... | 3 | memoize/decorator.py | ECrownofFire/chaos |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
############################
# File Name: parent_child_2.py
# Author: One Zero
# Mail: zeroonegit@gmail.com
# Created Time: 2015-12-28 23:23:13
############################
class Parent: # 定义父类
def myMethod(self):
print("调用父类方法")
class Child(Parent): #... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
... | 3 | runoob/basic_tutorial/parent_child_2.py | zeroonegit/python |
from app import babel
from flask import Blueprint, render_template, request, g, redirect, url_for
from flask_login import login_required
from flask_babel import gettext
from config import LANGUAGES
from app.main import main
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(LANGUAGES.k... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer":... | 3 | app/main/controllers.py | LukV/idnet |
class optimType:
REACTION_KO = 1
REACTION_UO = 2
GENE_KO = 3
GENE_UO = 4
MEDIUM = 5
MEDIUM_LEVELS = 6
MEDIUM_REACTION_KO = 7
MEDIUM_REACTION_UO = 8
COMPOSITION = 9
PROTEIN_KO = 10
PROTEIN_UO = 11
types = {1:"Reaction Knockouts",2:"Reaction Under/Over expression", 3:"Gene... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than... | 3 | src/optimModels/utils/constantes.py | BioSystemsUM/optimModels |
from typing import List, TYPE_CHECKING
from .bulk_update_cost_center_input_params import BulkUpdateCostCenterInputParams
from travelperk_python_api_types.cost_centers.cost_centers.bulk_update_response import (
BulkUpdateResponse,
)
from travelperk_http_python.dataclass_wrapper.dataclass_wrapper import DataclassWrap... | [
{
"point_num": 1,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than cla... | 3 | travelperk_http_python/cost_centers/bulk_update_cost_center_request.py | namelivia/travelperk-http-python |
import unittest
class TestRunnable(unittest.TestCase):
def test_almeq(self):
#(first, second, places=7, msg=None, delta=None)
self.assertAlmostEqual(1.0, 1.00000001, 7)
self.assertAlmostEqual(1.0, 1.00000001, 7, '''comment test''')
self.assertAlmostEqual(1.0, 1.00000001, msg='''com... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
... | 3 | tests/unittest/assertAlmostEqual.py | nanobowers/py2cr |
from pools import PoolTest
import eventlet
class EventletPool(PoolTest):
def init_pool(self, worker_count):
return eventlet.GreenPool(worker_count)
def map(self, work_func, inputs):
return self.pool.imap(work_func, inputs)
def init_network_resource(self):
return eventlet.import_p... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written ... | 3 | pools/eventlet.py | JohnStarich/python-pool-performance |
#!/usr/bin/env python3
from flask import Flask, render_template
import flask_site.model as model
def create_app(test_config=None):
"""Create and configure the app.
Parameters
----------
test_config - Defaults to None, but can be used to set
up config for testing.
Returns
-------
Returns the app.
""... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": false
},
{
"point_num": 2,
"id": "any_function_over_40_lines",
"question": "Is any function in this file longer than 40 lines?",
"answer": true
... | 3 | e_website/flask_site/__init__.py | EthanH43/text_generator |
"""
This file implements the base agent class.
"""
# Standard libraries
from abc import ABC, abstractmethod
from typing import TypeVar
# Third-party dependencies
import torch
# Type definitions
Action = TypeVar("Action")
# Need this for type hints, true base
# class is hidden.
Scheduler = TypeVar("Scheduler")
clas... | [
{
"point_num": 1,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer":... | 3 | torchagents/agent.py | BendeguzToth/torchagents |
#!/usr/bin/env python3
from concurrent.futures import ThreadPoolExecutor
import os
import rackspace_monitoring.providers
import rackspace_monitoring.types
import network
import scan
MAX_WORKERS = 100
DEFAULT_MONITORING_ZONES = \
("mzdfw", "mzord", "mziad", "mzlon", "mzhkg", "mzsyd")
def get_driver(user, api_k... | [
{
"point_num": 1,
"id": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/cls)?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fe... | 3 | monitoring.py | chriskuehl/mapman |
from discord.ext.commands import command
from discord.ext.commands.context import Context
from exceptions import PermissionDenied, InvalidArgs, OutOfServer
from tools import find_member
from cogs import BaseCog
class Members(BaseCog):
admin = True
@command(brief="ban member")
async def ban(self, ctx: Co... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},... | 3 | admin_cogs.py | dferndz/r2d2 |
from pipert2.core.base.routines import MiddleRoutine
from pipert2.utils.method_data import Method
DUMMY_ROUTINE_EVENT = Method("Change")
class DummyMiddleRoutine(MiddleRoutine):
def __init__(self, counter=0, **kwargs):
super().__init__(**kwargs)
self.counter = counter
self.inc = True
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "no_function_exceeds_5_params",
"question": "Does every function in this file take 5 or fewer parameters (excluding self/cls)... | 3 | tests/unit/pipert/core/utils/dummy_routines/dummy_middle_routine.py | MayoG/PipeRT2 |
from typing import *
import re
class Censorship:
def __init__(self, content: Union[Any, str, None] = None) -> None:
self.content: str = content
def update_content(self, content: Any):
self.content = content
def censor(self):
censored = ["fuck", "shit", "lmao", "lmfao", "porn", "s... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": ... | 3 | utils/censor.py | GlobalChatDev/DeveloperGlobalChat |
from agavepy.agave import AgaveError
from tapis_cli.display import Verbosity
from tapis_cli.clients.services.mixins import ServiceIdentifier, Username
from . import API_NAME, SERVICE_VERSION
from .models import SystemRole
from .formatters import SystemsFormatOne
__all__ = ['SystemsRolesShow']
class SystemsRolesShow... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": true
},
... | 3 | tapis_cli/commands/taccapis/v2/systems/roles_show.py | shwetagopaul92/tapis-cli-ng |
# Copyright 2021 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, sof... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},... | 3 | src/permission_manager/permission_manager/__init__.py | tessia-project/tessia-mesh |
# Copyright (c) 2018 Aaron LI <aly@aaronly.me>
# MIT License
"""
Custom Ansible template filters to crypt/hash passwords.
"""
import os
import base64
import crypt
import hashlib
def cryptpass(p):
"""
Crypt the given plaintext password with salted SHA512 scheme,
which is supported by Linux/BSDs.
"""
... | [
{
"point_num": 1,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": true
},
{
"point_num": 2,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false... | 3 | filter_plugins/passwd.py | liweitianux/ansible-dfly-vps |
#!python
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
import util
def test_delete():
util.copy_file('a.txt', 'a.txt.bak')
util.copy_dir('d1', 'd1_bak')
util.delete('a.txt')
util.delete('d1', force=True)
return 'delete OK'
def main():
s = test_delete()
util.sen... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": tru... | 3 | python/test/file/test_delete.py | takashiharano/util |
from rpip.output import Output
exit0 = {'exit_code': 0, 'stdout': 'yes', 'stderr': ''}
exit1 = {'exit_code': 1, 'stdout': '', 'stderr': 'ERROR'}
o0 = {'host1': exit0, 'host2': exit0, 'host3': exit0}
o1 = {'host1': exit0, 'host2': exit1, 'host3': exit0}
o2 = {'host1': exit0, 'host2': exit1, 'host3': exit1}
def test_... | [
{
"point_num": 1,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answer": false
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
... | 3 | rpip/tests/test_output.py | danielfrg/remote-pip |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.