source string | points list | n_points int64 | path string | repo string |
|---|---|---|---|---|
from __future__ import unicode_literals
import frappe
def set_default_address(doc,method):
if doc.is_primary_address:
for row in doc.links:
if row.link_doctype=="Customer":
cust = frappe.get_doc("Customer",row.link_name)
cust.default_address=doc.name
cust.save()
def set_default_contact(doc,method):
... | [
{
"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 | sfa/custom_function.py | erpsonic/en_sfa |
from typing import Type
import pytest
from cx_const import PredefinedActionsMapping
from cx_core import type as type_module
from cx_core.type_controller import TypeController
from pytest_mock.plugin import MockerFixture
from tests.test_utils import get_classes
def check_mapping(mapping: PredefinedActionsMapping) ->... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding se... | 3 | tests/unit_tests/cx_core/type/type_test.py | Crocmagnon/controllerx |
import click
from colorama import Fore, Style
class KsmCliException(click.ClickException):
in_a_shell = False
def colorize(self):
if KsmCliException.in_a_shell is False:
return str(self.message)
else:
return Fore.RED + str(self.message) + Style.RESET_ALL
def form... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": false
},
{... | 3 | integration/keeper_secrets_manager_cli/keeper_secrets_manager_cli/exception.py | Keeper-Security/secrets-manager |
import asyncio
import discord
import typing
from discord.ext import commands
async def wf_msg_or_reaction(
ctx: commands.Context,
*,
timeout: float = 120.0,
checks: typing.List[callable] = None,
message: discord.Message = None,
**pairs
):
"""
Waits for a message and/or a reaction, whi... | [
{
"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 | dds/custom/ext.py | dragdev-studios/custom.py |
from typing import Dict, List
import requests
from bs4 import BeautifulSoup # type: ignore[import]
class _RequestCache:
def __init__(self) -> None:
self._cache: Dict[str, BeautifulSoup] = {}
def __call__(self, page: str) -> BeautifulSoup:
if page.endswith(".html"):
page = page[:... | [
{
"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 | spec_parser/spec_parser/util.py | Parnassius/domify |
from sys import argv, exit
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setCentralWidget(CustomWidget(self))
self.show()
class Cus... | [
{
"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 | charlie2/_scratch/event_tester.py | sammosummo/Charlie2 |
import random
def choose():
words=['rainbow','computer','science','programming','mathematics','player','condition','reverse','water','board']
pick=random.choice(words)
return pick
def jumble(word):
jumbled="".join(random.sample(word,len(word)))
return jumbled
def thank(p1n,p2n,p1,p2):
print(p... | [
{
"point_num": 1,
"id": "any_function_over_40_lines",
"question": "Is any function in this file longer than 40 lines?",
"answer": true
},
{
"point_num": 2,
"id": "all_function_names_snake_case",
"question": "Are all function names in this file written in snake_case?",
"answer": t... | 3 | python programmes made by me/jumbled word game.py | sumon328/Hacktoberfest_contribution_2021 |
import pickle
import os
import numpy as np
import sys
from sklearn.preprocessing import label_binarize
from functionDefs import *
# All Cora data is stored as pickle
def pickle_read(path):
with open(path, "rb") as file:
data = pickle.load(file)
return data
def pickle_save(path, data):
with open(... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding self/... | 3 | python/binarize.py | JunyongLee1217/GEM_Web-Interface |
from __future__ import print_function
import math
import sys
import logging
logger = logging.getLogger('mortgage')
def get_current_rate(years):
logger.debug('Fetching current interest rate for %d years', years)
rate = 5.3 # Stub external service call
logger.debug('Service returned interest rate %f', rat... | [
{
"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 | logging_course/lesson3/task5/multiple_handlers.py | behzod/pycharm-courses |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
使用自建的接口识别来自网络的验证码
需要配置参数:
remote_url = "https://www.xxxxxxx.com/getImg" 验证码链接地址
rec_times = 1 识别的次数
"""
import datetime
import requests
from io import BytesIO
import time
import json
import os
def recognize_captcha(test_path, save_path, image_suffix):
image_... | [
{
"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 | recognize_local.py | Suchbear/cnn_captcha |
import requests
import re
import random
import time
from bs4 import BeautifulSoup
import os
import lpmysql
import json
def getindex():
url = 'http://freeget.co'
headers = {'User-Agent': "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 S... | [
{
"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 | freeget.py | leifufeng/free91 |
"""
CH 9.1 Applications/Image Augmentation
"""
from sklearn import model_selection
from keras import datasets
import keras
assert keras.backend.image_data_format() == 'channels_last'
from keraspp import aigen
class Machine(aigen.Machine_Generator):
def __init__(self):
(x_train, y_train), (x_test, y_test)... | [
{
"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 | ex9_1_applications_agumentation.py | soyoung9306/-3-keras |
"""Fixes common java command mistake
Example:
> java foo.java
Error: Could not find or load main class foo.java
"""
from thefuck.utils import for_app
@for_app('java')
def match(command, settings):
return command.script.endswith('.java')
def get_new_command(command, settings):
return command.script[:-5]
| [
{
"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 | thefuck/rules/java.py | Archstacker/thefuck |
import os
import requests
PRIMEHUB_DOMAIN_NAME = 'primehub-graphql.hub.svc.cluster.local'
if 'PRIMEHUB_DOMAIN_NAME' in os.environ:
PRIMEHUB_DOMAIN_NAME = os.environ['PRIMEHUB_DOMAIN_NAME']
ME_INFO = None
def __post_api_graphql(query, variables):
url = 'http://{}/api/graphql'.format(PRIMEHUB_DOMAIN_NAME)
... | [
{
"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 | primehub_job/utils.py | InfuseAI/primehub-job |
"""motiv synchronization primitives
Module:
Using a uniform interface to define synchronization
primitives helps us use multiple execution frameworks
without changing any of the code written.
for example, multiprocessing vs threading.
"""
import abc
class SystemEvent(abc.ABC):
"""Event abstract ... | [
{
"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 | motiv/sync/mixin.py | SaadTalaat/motiv |
"""gpxfile table
Revision ID: ba29ca77dbc3
Revises: 2dd5da4ccf72
Create Date: 2020-07-01 16:06:16.814147
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ba29ca77dbc3'
down_revision = '2dd5da4ccf72'
branch_labels = None
depends_on = None
def upgrade():
# ... | [
{
"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 | rest-api/migrations/versions/ba29ca77dbc3_gpxfile_table.py | Toxe/gps-tracks |
#!/usr/bin/python3
"""
Creando mi propio decorador
y entendiendolos
¿ Qué es un decorador ?
- Un decorador básicamente toma una función,
le añade alguna funcionalidad y la retorna.
"""
# Ejemplo:
def funcion_decorador(funcion):
def wrapper():
print("llamando a mi funcion")
funcion()
... | [
{
"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 | decoradores.py | daniela2001-png/PYTHON-REVIEW-TOPICS |
###############################################################################
#
# DONE:
#
# 1. READ the code below.
# 2. TRACE (by hand) the execution of the code,
# predicting what will get printed.
# 3. Run the code and compare your prediction to what actually was printed.
# 4. Decide whether you are... | [
{
"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 | src/m1r_functions.py | ColinBalitewicz/03-AccumulatorsAndFunctionsWithParameters |
"""Defines exceptions that can occur when interacting with interface data values"""
from util.exceptions import ValidationException
class InvalidData(ValidationException):
"""Exception indicating that the data is invalid"""
def __init__(self, name, description):
"""Constructor
:param name: T... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "every_class_has_docstring",
"question": "Does every class in this file have a docstring?",
"answer": true
},
{
... | 3 | scale/data/data/exceptions.py | kaydoh/scale |
import os
import sys
cwd = os.getcwd()
sys.path.append(cwd)
import time, math
import numpy as np
from pnc.interface import Interface
from config.manipulator_config import ManipulatorConfig
from pnc.robot_system.pinocchio_robot_system import PinocchioRobotSystem
class ManipulatorInterface(Interface):
def __init_... | [
{
"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 | pnc/manipulator_pnc/manipulator_interface.py | junhyeokahn/ASE389 |
#-*- coding: utf-8 -*-
from bson import ObjectId as _ObjectId
from datetime import datetime
__all__ = ['ObjectId', 'String', 'Integer', 'Float', 'Long', 'List', 'Boolean', 'DateTime']
class TypeMixin(object):
def is_valid(self, value):
raise NotImplementedError
def to_value(self):
raise No... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answe... | 3 | sixisles/types.py | teitei-tk/SixIsles |
from src.valtypes import Value
class SymbolTable:
def __init__(self, parent = None):
self.symbols = {}
self.parent = parent
def get(self, name)->Value:
value = self.symbols.get(name, None)
if value == None and self.parent:
return self.parent.get(name)
return ... | [
{
"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 | src/context/__init__.py | vanelk/vpp |
from rest_framework import fields, serializers
from db.models.repos import Repo
class RepoSerializer(serializers.ModelSerializer):
project = fields.SerializerMethodField()
class Meta:
model = Repo
fields = ('project', 'created_at', 'updated_at', 'is_public', )
def get_user(self, obj):
... | [
{
"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 | polyaxon/api/repos/serializers.py | elyase/polyaxon |
class Check:
def __init__ (self, x, y):
self.x = x
self.y = y
def getX(self):
return self.x
def getY(self):
return self.y
def check():
a = Check(1, 2)
b = Check(3, 4)
a.z = 5
b.z = 6
print(a.x, a.y, a.z)
def setup():
PER.setPeriod("Per1", 3)... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer":... | 3 | Poller/Check.py | kanutope/myCharm |
#!/usr/bin/env python
import requests
import json
from time import sleep
import base64
import rospy
from std_msgs.msg import string
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError
import cv2
bridge = CvBridge()
# Fix this to get an image file as a parameter (subscribe to a Node), and a... | [
{
"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 | vision.py | mateoguaman/Semantic-Autonomous-Mapping |
# Copyright 2021 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Engine shouldn't explode when step_test_data gets functools.partial.
This is a regression test for a bug caused by this revision:
http://src.c... | [
{
"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 | recipes/engine_tests/functools_partial.py | luci/recipes-py |
import sys
from io import StringIO
import unittest
from src.AOJ.ITP1_6_B import resolve
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
... | [
{
"point_num": 1,
"id": "any_function_over_40_lines",
"question": "Is any function in this file longer than 40 lines?",
"answer": true
},
{
"point_num": 2,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
... | 3 | tests/AOJ/test_ITP1_6_B.py | nabetama-training/CompetitionProgrammingPractice |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_codegen
----------------------------------
Tests for `codegen` module.
"""
import sys
import unittest
from contextlib import contextmanager
from click.testing import CliRunner
from codegen import codegen
from codegen import cli
class TestCodegen(unittest.Te... | [
{
"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": false
},... | 3 | jinja2/codegen/tests/test_codegen.py | lanen/libev_example |
class Topic:
def __init__(self, id: int, topic: str, storage_folder: str):
self.id = id
self.topic = topic
self.storage_folder = storage_folder
def edit(self, new_topic, new_storage_folder):
self.topic = new_topic
self.storage_folder = new_storage_folder
def __repr_... | [
{
"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 | attr_and_methods/topics/topic.py | borko81/SU_OOP_2021 |
import torch.nn.functional as F
import torch
import para_model
class ParaAvgModel(para_model.PARAModel):
def __init__(self, **args):
super().__init__(**args)
# self.drop_layer=torch.nn.Dropout(p=0.2)
self.cls_layer=torch.nn.Linear(self.bert.config.hidden_size*5, args['num_classes'])
d... | [
{
"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 | para_averaging.py | TurkuNLP/paraphrase-classification |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright [2017] Tatarnikov Viktor [viktor@tatarnikov.org]
#
# 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/licen... | [
{
"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 | Scopuli/Interfaces/WEB/Utils/Form.py | MaxOnNet/scopuli-core-web |
from ixnetwork_restpy.base import Base
from ixnetwork_restpy.files import Files
class FCoE_GTIN(Base):
__slots__ = ()
_SDM_NAME = 'fCoEGTIN'
_SDM_ATT_MAP = {
'FCoE Header': 'fCoEGTIN.header.fcoeHeader',
'FC Header': 'fCoEGTIN.header.fcHeader',
'FC_CT': 'fCoEGTIN.header.fcCT',
... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer": false
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answ... | 3 | ixnetwork_restpy/testplatform/sessions/ixnetwork/traffic/trafficitem/configelement/stack/fCoEGTIN_template.py | Vibaswan/ixnetwork_restpy |
import socket
from threading import Thread
socketList = []
def waitConnect(s):
"""
cmd format --> # -H $IP -p $PORT -c <start|stop>
"""
while True:
sock, addr = s.accept()
if sock not in socketList:
socketList.append(sock)
def sendCmd(cmd):
print("Send command......"... | [
{
"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 | shiyanlou_cs683/server.py | tongxindao/shiyanlou |
from typing import Tuple
import torch
import torch.nn as nn
import kornia
from kornia.filters.kernels import get_laplacian_kernel2d
class Laplacian(nn.Module):
r"""Creates an operator that returns a tensor using a Laplacian filter.
The operator smooths the given tensor with a laplacian kernel by convolving... | [
{
"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 | kornia/filters/laplacian.py | varunagrawal/kornia |
from adia.sequence import Module
from adia.renderer import ModulePlan, ItemStartPlan, ItemEndPlan, LEFT, RIGHT
def test_moduleplan():
p = ModulePlan(Module('foo'))
assert repr(p) == 'ModulePlan: foo'
def test_itemplans():
class Item:
def __repr__(self):
return 'foo -> bar'
item ... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answe... | 3 | tests/test_renderer.py | saeedou/adia |
#!/usr/bin/env python3
'''
Use the Neural Engineering framework to solve Pendulum via an elitist GA
Copyright (C) 2020 Simon D. Levy
MIT License
'''
from lib import NefGym
from sys import argv
import pickle
import numpy as np
from sueap.algorithms.elitist import Elitist
class NefPendulum(NefGym):
def __init__... | [
{
"point_num": 1,
"id": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"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... | 3 | gym/pendulum_test.py | simondlevy/TinyNEF |
def get_account(user):
from .models import Account
return Account.objects.for_user(user)
def get_data(request):
from .util import account_data
return account_data(request)
| [
{
"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_nested_function_def",
"question": "Does this file contain any function defined inside another function?... | 3 | shoptools/contrib/accounts/__init__.py | gregplaysguitar/django-shoptools |
from abc import ABC, abstractmethod
from pathlib import Path
import torch
from torch import Tensor
from torch.utils.data import Dataset, DataLoader
class BaseDataModule(ABC):
def __init__(
self,
data_path: Path,
batch_size: int,
num_workers: int,
):
... | [
{
"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 | sonata/datamodules/base_datamodule.py | sergevkim/sonata |
"""
"""
from __future__ import absolute_import
import sys
import traceback
import click
DEBUG = False
def debug(message, *args):
if args:
message = message % args
if DEBUG:
click.echo(message)
def info(message, *args, **kwargs):
if args:
message = message % args
fg = kwar... | [
{
"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 | starforge/io.py | pcm32/starforge |
# Simple Threads Pool
from multiprocessing.dummy import Pool as ThreadPool
from datetime import date
from datetime import datetime
import time
multiply_results = []
def squareNumber(n):
multiply_results.append(n ** 2)
dt_string = datetime.now().strftime("%H:%M:%S")
millis = int(round(time.time() * 1000))
... | [
{
"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_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excluding se... | 3 | threads/simple_threads.py | bchekuri/python101 |
import os
from skimage import img_as_ubyte
from skimage.io import imread, imsave
from skimage.transform import resize
def create_folder_for_file_path(file_path):
resized_image_dir = os.path.dirname(file_path)
os.makedirs(resized_image_dir, exist_ok=True)
def read_image(source_image_path):
return imread(... | [
{
"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 | .github/actions/skimage-resizer/src/shared/resize_image_handler.py | josecelano/data-version-control |
# Generated by Django 3.0.14 on 2021-09-24 14:19
import json
from django.db import migrations
def update_config(apps, schema_editor):
StudyType = apps.get_model("studies.StudyType")
external = StudyType.objects.get(name="External")
config = json.loads(external.configuration)
config["metadata"]["fiel... | [
{
"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 | studies/migrations/0076_update_external_study_type.py | manybabies/MBAH-LookIt-API |
import click
from colorama import Fore
from .transactions import print_transaction
class ClickProgressBarUpdater:
def __init__(self, bar):
self.bar = bar
self.progress = 0
def __call__(self, progress):
self.bar.update(progress - self.progress)
self.progress = progress
@clic... | [
{
"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": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | saldo/cli/fetch.py | dr-duplo/python-saldo |
from flask import Flask, request, jsonify, render_template, make_response
from qual_id.pattern import Pattern
import random
app = Flask(__name__)
@app.route('/get/', methods=['GET'])
def get_response():
pattern = Pattern(request.args.get("pattern", ""))
number = int(request.args.get("number", 1))
response_obj... | [
{
"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 | app.py | aldinaufal21/qual-id |
from enum import Enum, IntEnum, auto, unique
@unique
class Classification(IntEnum):
PUBLIC = -1
RESTRICTED = 0
CONFIDENTIAL = 1
@unique
class Role(Enum):
AGENT = 'agent'
SERVICE = 'service'
STORAGE = 'storage'
@unique
class Profile(Enum):
BLACK = 'black'
GREY = 'grey'
WHITE = '... | [
{
"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 | dfdone/enums.py | elespike/dfdone |
import datetime
from docxtpl import DocxTemplate
from docxtpl import InlineImage
from docxtpl import DocxTemplate, InlineImage
# source = []
with open('source.txt') as s:
source = s.read()
source = source.split('\n')
print(type(source),source)
def get_context(producer, model, fuel, price): # возвращает ... | [
{
"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 | main.py | Dudaltsov128/Lesson_7 |
# -*- coding: utf-8 -*-
from decimal import Decimal, InvalidOperation
from django import template
from django.utils import formats
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
# from django.utils.http import urlquote
from django.conf import settings
# import logging
from... | [
{
"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 | gsb/templatetags/gsb_extras.py | pfrancois/grisbi_django |
from Acquire.ObjectStore import Function
import pytest
def _test_sum(a, b):
return a + b
def test_function():
f = Function(_test_sum)
assert(f(a=1, b=3) == 4)
data = f.to_data()
g = Function.from_data(data)
assert(g(a=1, b=3) == 4)
f = Function(_test_sum, b=10)
assert(f(a=1)... | [
{
"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 | test/ObjectStore/test_function.py | samle-appsbroker/acquire |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
from tests.utils import pipeline_settings
class MiddlewareTest(TestCase):
def test_middleware_off(self):
response = self.client.g... | [
{
"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/tests/test_middleware.py | peopledoc/django-pipeline |
import numpy as np
from murt.utils import objreader
import os
import sys
COMPONENT_PATH = os.path.join(sys.prefix, "murt-assets")
class Object():
def __init__(self, object_name, file_path=None, directory_path=None):
self.object_name = object_name
self.scale, self.translate, self.rotate = \
... | [
{
"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 | murt/utils/object.py | tamsri/murt |
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@test.com',
... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer":... | 3 | app/core/tests/test_admin.py | rodnaskorn/recipe-app-api |
#!/usr/bin/env python3
"""
Read a lists of IP addresses from file and performs a HEAD request.
Outputs HTTP response code, IP address and HTTP headers.
"""
import asyncio
import time
import aiohttp
from pathlib import Path
import sys
async def get_header(session, ip):
async with session.head(f"http://{ip}/", all... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docst... | 3 | HTTP_scan/async_http_response_code_checker.py | esirotinski/py3 |
import os
import shutil
import stat
def copy(src, dst, symlinks = False, ignore = None):
ign = shutil.ignore_patterns(ignore)
copytree(src,dst,symlinks,ign)
def copytree(src, dst, symlinks = False, ignore = None):
if not os.path.exists(dst):
os.makedirs(dst)
shutil.copystat(src, dst)
lst = os.listdir... | [
{
"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": fal... | 3 | ezex/util.py | SimonRamstedt/ezex |
# -*- coding: utf-8 -*-
import unittest.mock
import pytest
import pycamunda.task
from tests.mock import raise_requests_exception_mock, not_ok_response_mock
def test_claim_params(engine_url):
claim_task = pycamunda.task.Claim(url=engine_url, id_='anId', user_id='anUserId')
assert claim_task.url == engine_u... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docst... | 3 | tests/task/test_claim.py | asyncee/pycamunda |
from ccdc import tile
from pyspark.sql import Row
import datetime
import json
import test
rows = [Row(tx=0,
ty=1,
name='test model',
model='model coefficients',
updated='0001-01-01')]
def test_table():
assert 'tile' == tile.table()
def test_schema():
s = til... | [
{
"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 | test/test_tile.py | USGS-EROS/lcmap-gen |
# coding: utf-8
"""
Isilon SDK
Isilon SDK - Language bindings for the OneFS API # noqa: E501
OpenAPI spec version: 6
Contact: sdk@isilon.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import isi_sdk_8_1_1
from i... | [
{
"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": false
},... | 3 | isi_sdk_8_1_1/test/test_providers_summary_provider_instance.py | mohitjain97/isilon_sdk_python |
# from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up logge... | [
{
"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 | tiled/database/migrations/env.py | stuartcampbell/tiled |
from dataclasses import dataclass
import os
@dataclass
class Track:
title: str
artist: str
album: str
length: str
artwork: str
artworkFilePath: str
artworkBaseURL: str
uniqueId: str
ignore: bool
def getArtworkPath(self):
unglobbed = os.path.expanduser(self.artworkFile... | [
{
"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 | Track.py | seanth/nicecast-trackupdate |
import unittest
import xml.etree.ElementTree as ET
from programy.bot import Bot
from programy.brain import Brain
from programy.config import ClientConfiguration, BrainConfiguration
from programy.dialog import Question, Sentence
from programy.parser.template.graph import TemplateGraph
from programy.parser.template.node... | [
{
"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 | src/test/parser/template/graph/test_basics.py | ajit2688/program-y-chatbot |
""" tests chemkin_io.writer.mechanism.species_block
"""
from chemkin_io.writer.mechanism import species_block as writer
from chemkin_io.parser.species import names as parser
SPC_IDENT_DCT = {
'O': {'smiles': 'smiles_1',
'inchi': 'inchi_1',
'charge': '',
'mult': '',
'sens': ... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"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 | autoio-interfaces/chemkin_io/tests/test__species_write_read.py | lpratalimaffei/autoio |
import unittest
from wiki_dump_reader import Cleaner
class TestRemoveEmphasis(unittest.TestCase):
def setUp(self):
self.cleaner = Cleaner()
def test_remove_emphasis_bold(self):
text = "'''游戏工具编程'''是指采用各种开发工具进行开发修改[[电脑]]、[[电视]][[游戏]]的过程。主要的开发工具有以下几大类"
expected = '游戏工具编程是指采用各种开发工具进行开发修... | [
{
"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 | tests/test_remove_emphasises.py | PoWWoP/wiki-dump-reader |
# Prirejeno po datotekah iz predavanj in vaj.
import csv
import json
import os
import requests
default_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
# Prenos spletne strani
def url_v_html(url, mapa, ime_datotek... | [
{
"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 | orodja.py | benoucakar/analiza-podatkov---Najbolj-ih-10000-videoiger |
import torch
import torch.nn as nn
class Normalize_layer(nn.Module):
def __init__(self, mean, std):
super(Normalize_layer, self).__init__()
self.mean = nn.Parameter(torch.Tensor(mean).unsqueeze(1).unsqueeze(1),
requires_grad=False)
self.std = nn.Parameter(... | [
{
"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 | cnns/nnlib/robustness/pni/code/models/nomarlization_layer.py | anonymous-user-commits/perturb-net |
from __future__ import print_function, absolute_import, unicode_literals
from zope.interface import implementer
import contextlib
from ._interfaces import IJournal
@implementer(IJournal)
class Journal(object):
def __init__(self, save_checkpoint):
self._save_checkpoint = save_checkpoint
self._outbou... | [
{
"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 | src/wormhole/journal.py | Baeumla/magic-wormhole |
import sys
import hashlib
def check(args):
if len(args) != 2:
print("usage hashme.py <phrase>")
return False
return True
def main(phrase):
salt ='Km5d5ivMy8iexuHcZrsD'
hash_obj = hashlib.pbkdf2_hmac('sha512', phrase.encode(), salt.encode(), 200000)
print(hash_obj.hex())
if check(sys.argv): main(sys.argv[1])... | [
{
"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 | 03 - Linux Security/q6/hashme.py | HirumalPriyashan/linux-training |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flatbuf
import flatbuffers
class FloatingPoint(object):
__slots__ = ['_tab']
@classmethod
def GetRootAsFloatingPoint(cls, buf, offset):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x ... | [
{
"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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"ans... | 3 | thirdparty/org/apache/arrow/flatbuf/FloatingPoint.py | mrocklin/pygdf |
import cv2
import sys
sys.path.append(".")
from glimg import detbbox as glbbox
from glimg import visualizer as glvis
image_path = "example/images/img1.jpg"
def test_draw_bbox():
img = cv2.imread(image_path)
bbox1 = [100, 100, 200, 200]
bbox2 = [150, 150, 25, 25]
img = glvis.draw_bbox(img, bbox1, wid... | [
{
"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 | example/visualizer_test.py | chencgln/glimg |
import jwt
from http.cookies import SimpleCookie
from datetime import datetime
from _main_.settings import SECRET_KEY
from database.models import UserProfile
def setupCC(client):
client.post('/cc/import',
{ "Confirm": "Yes",
"Actions":"carbon_calculator/content/Actions.csv",
... | [
{
"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/api/tests/common.py | owenplesko/api |
# coding: utf-8
"""
Wavefront REST API
<p>The Wavefront REST API enables you to interact with Wavefront servers using standard REST API tools. You can use the REST API to automate commonly executed operations such as automatically tagging sources.</p><p>When you make REST API calls outside the Wavefront REST ... | [
{
"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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"ans... | 3 | test/test_access_policy_rule_dto.py | httpsgithu/python-client |
#!/usr/bin/env python
# coding=utf-8
#
# Block for making tree copies
#
from __future__ import unicode_literals
from pytreex.core.block import Block
__author__ = "Ondřej Dušek"
__date__ = "2012"
class SetGlobal(Block):
def __init__(self, scenario, args):
"""\
Constructor, sets the arguments giv... | [
{
"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 | pytreex/block/util/setglobal.py | ufal/pytreex |
from flask_login import UserMixin
class User(UserMixin):
def __init__(self, id_, name, password, roles,rid):
self.id = id_
self.rid = rid
self.name = name
self.password = password
self.roles = roles
def has_role(self, role):
return role in self.roles | [
{
"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 | src/security/user.py | sanjeethbti/wrldc_docs_search_portal |
from ....driver.location import CloudLocationMonitor
class RegionMonitor(CloudLocationMonitor):
@staticmethod
async def create(default_region: str) -> 'RegionMonitor':
return RegionMonitor(default_region)
def __init__(self, default_region: str):
self._default_region = default_region
... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answ... | 3 | batch/batch/cloud/azure/driver/regions.py | jkgoodrich/hail |
#!/usr/bin/python3
import sys
import pathlib
from datetime import datetime
import pytest
from falcon import testing
sys.path.append( str(pathlib.Path(__file__).resolve().parent) + '/../' )
import main
@pytest.fixture()
def client():
return testing.TestClient(main.create_service())
def test_api_version(clien... | [
{
"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 | test/api_test.py | kuro2a/kiku |
import unittest
from simuloc.signal import Generator
class GeneratorTestCase(unittest.TestCase):
"""GeneratorTestCase tests the generator class."""
def setUp(self):
"""Creates a instance of the generator class."""
self.cinst = Generator()
def tearDown(self):
pass
def test_noi... | [
{
"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_signal/test_generator.py | mcanatalay/SIMULOC |
""" Utilities for Cloud Backends """
def parse_remote_path(remote_path):
"""
Parses a remote pathname into its protocol, bucket, and key. These
are fields required by the current cloud backends
"""
# Simple, but should work
fields = remote_path.split("/")
assert len(fields) > 3, "Improper... | [
{
"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 | synaptor/io/backends/utils.py | ZettaAI/Synaptor |
class Employees(object):
_employees = {}
_headcount = 0
def add_employee(self, employee):
self._headcount += 1
self._employees[self._headcount] = employee
def get_employee(self, i):
return self._employees[i]
@property
def headcount(self):
return self._headcount... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": true
},
{
"point_num": 2,
"id": "has_nested_function_def",
"question": "Does this file contain any function defined inside another function?",
"answe... | 3 | DesignPatterns/05_iterator/1_no_iterator/employee_collection.py | eduardormonteiro/PythonPersonalLibrary |
# -*- coding=UTF-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import doctest
import sys
import pytest
import phrases_case
@pytest.mark.skipif(sys.version_info < (3,), reason="requires python3")
def test_doc():
doctest.testmod(phrases_case)
... | [
{
"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 | tests/test_phrases_case.py | NateScarlet/phrases-case |
import unittest
from zolegame.room import Room
from zolegame.player import Player
from bots.random_player import RandomPlayer
from zolegame.players import PlayerInterface
class RoomTest(unittest.TestCase):
def setUp(self):
self.playerA = PlayerInterface()
self.playerB = PlayerInterface(... | [
{
"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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"ans... | 3 | tests/zolegame/room_test.py | marisabele/Zole |
from multiprocessing.sharedctypes import Value
from global_vars import *
from utils import *
def state_inp_to_str(state_inp):
state_str = ''
for ch in state_inp:
state_str += str((['b', 'y', 'g'].index(ch)))
return state_str
def get_state_input():
valid = False
while not valid:
... | [
{
"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 | solver.py | gtxn/wordle-solver |
from django.shortcuts import render
from rest_framework import generics, authentication, permissions
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.settings import api_settings
from user.serializers import UserSerializer, AuthTokenSerializer
class CreateUserView(generics.CreateAPIVie... | [
{
"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 | anilbpoyraz/recipe-app-api |
""" Enums used in different API endpoints """
from enum import Enum
class PluginStatusState(str, Enum):
"""State of the plugin"""
NOTRUNNING = "NotRunning"
STARTING = "Starting"
RUNNING = "Running"
FAILEDTOSTART = "FailedToStart"
FAILEDTOSTAYRUNNING = "FailedToStayRunning"
STOPPING = "Sto... | [
{
"point_num": 1,
"id": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answer": false
},
{
"point_num": 2,
"id": "all_return_types_annotated",
"question": "Does every function in this file have a return type annotation?",
"answer... | 3 | matterapi/enums.py | gmerz/MatterApi |
#!/usr/bin/env python
#from:http://www.wooyun.org/bugs/wooyun-2010-093049
import re,time
def assign(service, arg):
if service == "umail":
return True, arg
def audit(arg):
url = arg + '/webmail/fast/index.php?module=operate&action=login'
postdata = 'mailbox=test@domain.com&link=?'
... | [
{
"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 | Bugscan_exploits-master/exp_list/exp-1063.py | csadsl/poc_exp |
from random import randint
class Die():
def __init__(self, sides):
self.sides = sides
def roll_die(self):
print(randint(1,self.sides)) | [
{
"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 | python/die.py | karandiip/PythonCrashCourse |
# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not... | [
{
"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 | py/selenium/webdriver/webkitgtk/service.py | stevepiercy/selenium |
import unittest.mock as mock
from tensortrade.oms.orders.criteria import Limit
from tensortrade.oms.instruments import USD, BTC
from tensortrade.oms.orders import TradeSide
def test_init():
criteria = Limit(limit_price=7000.00)
assert criteria.limit_price == 7000.00
@mock.patch('tensortrade.exchanges.Exch... | [
{
"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 | tests/tensortrade/unit/oms/orders/criteria/test_limit.py | zeeshanalipanhwar/tensortrade |
import sys
from collections import deque
import numpy as np
class Player():
def __init__(self, id, deck):
self.id = id
self.deck = deque(deck)
def __str__(self):
return f'<Player({self.id}, {self.deck})>'
def __repr__(self):
return str(self)
def play_card(self):
... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than clas... | 3 | day22/day22.py | KungCheops/aoc2020 |
"""
Utility for model
"""
import pathlib
import os
import json
def save_list_to_file(path, thelist):
with open(path, 'w') as f:
for item in thelist:
f.write("%s\n" % item)
def mkdir_p(full_dir):
"""Simulate mkdir -p"""
if not os.path.exists(full_dir):
pathlib.Path(full_dir).mk... | [
{
"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/utils.py | VVCepheiA/Prototypical-Networks-for-Few-shot-Learning-PyTorch |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.12.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import os
import sys
i... | [
{
"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": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"ans... | 3 | kubernetes/test/test_v1beta2_deployment_status.py | anemerovsky-essextec/python |
from enum import Enum
from schematics.exceptions import DataError
from schematics.models import Model
from schematics.types import StringType, DateTimeType, DecimalType
class ResultStatus(str, Enum):
OK = 'ok'
PENDING = 'pending'
ERROR = 'error'
class CommandResult(object):
def __init__(self, statu... | [
{
"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 | application/commands.py | pachecobruno/python-ddd |
import cProfile, pstats, io
import re
import VM
def Stats(pr):
s = io.StringIO()
sortby = 'tottime'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
def parse_code(code: str) -> bytes:
binary = ''
regex = re.compile(r"[0-9a-f]+:\s+([^;]+)\s*;.*", re... | [
{
"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 | example_BYTES.py | djtech-dev/PyVM |
import unittest
from cmpcodesize.compare import listFunctionSizes
class ListFunctionSizesTestCase(unittest.TestCase):
def test_when_size_array_is_none_raises(self):
with self.assertRaises(TypeError):
listFunctionSizes(None)
def test_when_size_array_is_empty_returns_none(self):
se... | [
{
"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": "more_functions_than_classes",
"question": "Does this file define more functions than classes?",
"answ... | 3 | utils/cmpcodesize/tests/test_list_function_sizes.py | truecat/swift |
# https://www.hackerrank.com/challenges/30-testing/problem
def minimum_index(seq):
if len(seq) == 0:
raise ValueError("Cannot get the minimum value index from an empty sequence")
min_idx = 0
for i in range(1, len(seq)):
if seq[i] < seq[min_idx]:
min_idx = i
return min_idx
... | [
{
"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 | python/src/hackerrank/2020/testing.py | ccampo133/coding-challenges |
# -*- coding: utf-8 -*-
__author__ = 'vincent'
import uuid
import json
from redis_help import redis_client
from werkzeug.security import generate_password_hash, check_password_hash
from . import redis_help
# 下面这个包 itsdangerous 用于生成确认令牌
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
def gen... | [
{
"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_has_docstring",
"question": "Does every function in this file have a docst... | 3 | app/utils/token_help.py | luwenchang/service-template-py |
# -*- coding: utf-8 -*-
'''
Tests for the rabbitmq state
'''
# Import python libs
from __future__ import absolute_import
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import skip_if_not_root
from tests.support.mixins import SaltReturnAssertsMixin
@skip_if_not_root
c... | [
{
"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": "has_multiple_inheritance",
"question": "Does any class in this file use multiple inheritance?",
"answer":... | 3 | tests/integration/states/test_rabbitmq_vhost.py | jubrad/salt |
import argparse
import requests
import time
import random
def get_arguments():
parser = argparse.ArgumentParser(description="path")
parser.add_argument("--url-file", type=str, default='',
help="url file path",
required=True)
parser.add_argument("--output-dir"... | [
{
"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 | parse_html.py | BeyondHeaven/parse_html |
from typing import Union
from cryptography.fernet import Fernet
class EncryptedString:
_key: bytes = NotImplemented
_val: str
_f = False
@property
def value(self) -> str:
return Fernet(self._key).decrypt(self._val.encode('utf-8')).decode('utf-8')
@value.setter
def value(self, val... | [
{
"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 | src/data/types/_encripted_string.py | Freonius/tranquillity |
import requests
from bs4 import BeautifulSoup
def request_git_hub_trending(url):
return requests.get(url)
def extract(page):
soup = BeautifulSoup(page.text, "html.parser")
return soup.find_all("article")
def transform(html_repos):
result = []
for row in html_repos:
developer_name = ''.j... | [
{
"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": "all_params_annotated",
"question": "Does every function parameter in this file have a type annotation (excludi... | 3 | my_first_scraper.py | ismoilov299/my_first_program |
from django.shortcuts import render
from rest_framework import serializers, viewsets, generics
from apps.scraper.models import Libros, Categorias
from django.http import JsonResponse
# Create your views here.
class libros_serializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Libros
... | [
{
"point_num": 1,
"id": "every_class_has_docstring",
"question": "Does every class 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": false
},
{... | 3 | techk/apps/rest/views.py | felipesantander/fullstack-challenge |
# Copyright (c) 2012-2021, Mark Peek <mark@peek.org>
# All rights reserved.
#
# See LICENSE file for full license.
from .aws import Action as BaseAction
from .aws import BaseARN
service_name = "AWS CodeStar Connections"
prefix = "codestar-connections"
class Action(BaseAction):
def __init__(self, action: str = N... | [
{
"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 | awacs/codestar_connections.py | alanjjenkins/awacs |
# Copyright 2019-2020 Amazon.com, Inc. or its affiliates. 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. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" fi... | [
{
"point_num": 1,
"id": "every_function_has_docstring",
"question": "Does every function in this file have a docstring?",
"answer": true
},
{
"point_num": 2,
"id": "every_function_under_20_lines",
"question": "Is every function in this file shorter than 20 lines?",
"answer": fals... | 3 | src/mlio-py/mlio/integ/scipy.py | babak2520/ml-io |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.