Dataset Viewer
Auto-converted to Parquet Duplicate
instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Generate docstrings for each module
# -*- coding: utf-8 -*- import re import sys import random from typing import List, Tuple import requests from requests.models import Response def find_links_in_text(text: str) -> List[str]: link_pattern = re.compile(r'((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()...
--- +++ @@ -10,6 +10,7 @@ def find_links_in_text(text: str) -> List[str]: + """Find links in a text and return a list of URLs.""" link_pattern = re.compile(r'((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`...
https://raw.githubusercontent.com/public-apis/public-apis/HEAD/scripts/validate/links.py
Add docstrings that explain purpose and usage
#!/usr/bin/env python3 import sys import os import argparse import re import yaml from bidi.algorithm import get_display def load_config(path): # Default configuration values default = { 'ltr_keywords': [], 'ltr_symbols': [], 'pure_ltr_pattern': r"^[\u0000-\u007F]+$", # Matches ASCII ...
--- +++ @@ -1,4 +1,23 @@ #!/usr/bin/env python3 +""" +RTL/LTR Markdown Linter. + +This script analyzes Markdown files to identify potential issues +in the display of mixed Right-To-Left (RTL) and Left-To-Right (LTR) text. +It reads configuration from a `rtl_linter_config.yml` file located in the same +directory as the ...
https://raw.githubusercontent.com/EbookFoundation/free-programming-books/HEAD/scripts/rtl_ltr_linter.py
Write docstrings that follow conventions
from abc import ABCMeta, abstractmethod from enum import Enum import sys class Suit(Enum): HEART = 0 DIAMOND = 1 CLUBS = 2 SPADE = 3 class Card(metaclass=ABCMeta): def __init__(self, value, suit): self.value = value self.suit = suit self.is_available = True @proper...
--- +++ @@ -38,6 +38,7 @@ return True if self._value == 1 else False def is_face_card(self): + """Jack = 11, Queen = 12, King = 13""" return True if 10 < self._value <= 13 else False @property @@ -90,6 +91,7 @@ return max_under if max_under != -sys.MAXSIZE else min_over ...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/object_oriented_design/deck_of_cards/deck_of_cards.py
Create docstrings for reusable components
# -*- coding: utf-8 -*- class QueryApi(object): def __init__(self, memory_cache, reverse_index_cluster): self.memory_cache = memory_cache self.reverse_index_cluster = reverse_index_cluster def parse_query(self, query): ... def process_query(self, query): query = self.par...
--- +++ @@ -8,6 +8,9 @@ self.reverse_index_cluster = reverse_index_cluster def parse_query(self, query): + """Remove markup, break text into terms, deal with typos, + normalize capitalization, convert to use boolean operations. + """ ... def process_query(self, query)...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/system_design/query_cache/query_cache_snippets.py
Provide clean and structured docstrings
from abc import ABCMeta, abstractmethod from enum import Enum class VehicleSize(Enum): MOTORCYCLE = 0 COMPACT = 1 LARGE = 2 class Vehicle(metaclass=ABCMeta): def __init__(self, vehicle_size, license_plate, spot_size): self.vehicle_size = vehicle_size self.license_plate = license_pl...
--- +++ @@ -92,9 +92,11 @@ return spot def _find_available_spot(self, vehicle): + """Find an available spot where vehicle can fit, or return None""" pass def _park_starting_at_spot(self, spot, vehicle): + """Occupy starting at spot.spot_number to vehicle.spot_size.""" ...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/object_oriented_design/parking_lot/parking_lot.py
Help me comply with documentation standards
class Node(object): def __init__(self, results): self.results = results self.next = next class LinkedList(object): def __init__(self): self.head = None self.tail = None def move_to_front(self, node): pass def append_to_front(self, node): pass de...
--- +++ @@ -30,6 +30,10 @@ self.linked_list = LinkedList() def get(self, query): + """Get the stored query result from the cache. + + Accessing a node updates its position to the front of the LRU list. + """ node = self.lookup.get(query) if node is None: ...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/object_oriented_design/lru_cache/lru_cache.py
Add detailed docstrings explaining each function
# -*- coding: utf-8 -*- class PagesDataStore(object): def __init__(self, db): self.db = db pass def add_link_to_crawl(self, url): pass def remove_link_to_crawl(self, url): pass def reduce_priority_link_to_crawl(self, url): pass def extract_max_priority_...
--- +++ @@ -8,21 +8,27 @@ pass def add_link_to_crawl(self, url): + """Add the given link to `links_to_crawl`.""" pass def remove_link_to_crawl(self, url): + """Remove the given link from `links_to_crawl`.""" pass def reduce_priority_link_to_crawl(self, url): ...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/system_design/web_crawler/web_crawler_snippets.py
Write reusable docstrings
# -*- coding: utf-8 -*- from mrjob.job import MRJob class SalesRanker(MRJob): def within_past_week(self, timestamp): ... def mapper(self, _, line): timestamp, product_id, category, quantity = line.split('\t') if self.within_past_week(timestamp): yield (category, product_...
--- +++ @@ -6,17 +6,56 @@ class SalesRanker(MRJob): def within_past_week(self, timestamp): + """Return True if timestamp is within past week, False otherwise.""" ... def mapper(self, _, line): + """Parse each log line, extract and transform relevant lines. + + Emit key value ...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/system_design/sales_rank/sales_rank_mapreduce.py
Add docstrings to incomplete code
# -*- coding: utf-8 -*- from mrjob.job import MRJob class SpendingByCategory(MRJob): def __init__(self, categorizer): self.categorizer = categorizer ... def current_year_month(self): ... def extract_year_month(self, timestamp): ... def handle_budget_notifications(s...
--- +++ @@ -10,26 +10,43 @@ ... def current_year_month(self): + """Return the current year and month.""" ... def extract_year_month(self, timestamp): + """Return the year and month portions of the timestamp.""" ... def handle_budget_notifications(self, key, t...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/system_design/mint/mint_mapreduce.py
Create simple docstrings for beginners
# -*- coding: utf-8 -*- from mrjob.job import MRJob class HitCounts(MRJob): def extract_url(self, line): pass def extract_year_month(self, line): pass def mapper(self, _, line): url = self.extract_url(line) period = self.extract_year_month(line) yield (period, u...
--- +++ @@ -6,20 +6,36 @@ class HitCounts(MRJob): def extract_url(self, line): + """Extract the generated url from the log line.""" pass def extract_year_month(self, line): + """Return the year and month portions of the timestamp.""" pass def mapper(self, _, line): +...
https://raw.githubusercontent.com/donnemartin/system-design-primer/HEAD/solutions/system_design/pastebin/pastebin.py
Add docstrings for better understanding
#!/usr/bin/env python3 import json import os import re import sys from datetime import datetime, timezone from pathlib import Path import httpx from build import extract_github_repo, load_stars CACHE_MAX_AGE_HOURS = 12 DATA_DIR = Path(__file__).parent / "data" CACHE_FILE = DATA_DIR / "github_stars.json" README_PATH...
--- +++ @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""Fetch GitHub star counts and owner info for all GitHub repos in README.md.""" import json import os @@ -20,6 +21,7 @@ def extract_github_repos(text: str) -> set[str]: + """Extract unique owner/repo pairs from GitHub URLs in markdown text.""" repos = set...
https://raw.githubusercontent.com/vinta/awesome-python/HEAD/website/fetch_github_stars.py
Document all public functions with docstrings
from __future__ import annotations import re from typing import TypedDict from markdown_it import MarkdownIt from markdown_it.tree import SyntaxTreeNode from markupsafe import escape class AlsoSee(TypedDict): name: str url: str class ParsedEntry(TypedDict): name: str url: str description: str...
--- +++ @@ -1,3 +1,4 @@+"""Parse README.md into structured section data using markdown-it-py AST.""" from __future__ import annotations @@ -39,6 +40,7 @@ def slugify(name: str) -> str: + """Convert a category name to a URL-friendly slug.""" slug = name.lower() slug = _SLUG_NON_ALNUM_RE.sub("", slu...
https://raw.githubusercontent.com/vinta/awesome-python/HEAD/website/readme_parser.py
Help me document legacy Python code
#!/usr/bin/env python3 import json import re import shutil from pathlib import Path from typing import TypedDict from jinja2 import Environment, FileSystemLoader from readme_parser import parse_readme, slugify # Thematic grouping of categories. Each category name must match exactly # as it appears in README.md (the ...
--- +++ @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +"""Build a single-page HTML site from README.md for the awesome-python website.""" import json import re @@ -153,6 +154,7 @@ categories: list[dict], resources: list[dict], ) -> list[dict]: + """Organize categories and resources into thematic section group...
https://raw.githubusercontent.com/vinta/awesome-python/HEAD/website/build.py
Generate docstrings with examples
from __future__ import annotations class IIRFilter: def __init__(self, order: int) -> None: self.order = order # a_{0} ... a_{k} self.a_coeffs = [1.0] + [0.0] * order # b_{0} ... b_{k} self.b_coeffs = [1.0] + [0.0] * order # x[n-1] ... x[n-k] self.input_h...
--- +++ @@ -2,6 +2,26 @@ class IIRFilter: + r""" + N-Order IIR filter + Assumes working with float samples normalized on [-1, 1] + + --- + + Implementation details: + Based on the 2nd-order function from + https://en.wikipedia.org/wiki/Digital_biquad_filter, + this generalized N-order functi...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/audio_filters/iir_filter.py
Add docstrings to make code maintainable
def backtrack( partial: str, open_count: int, close_count: int, n: int, result: list[str] ) -> None: if len(partial) == 2 * n: # When the combination is complete, add it to the result. result.append(partial) return if open_count < n: # If we can add an open parenthesis, do...
--- +++ @@ -1,8 +1,35 @@+""" +author: Aayush Soni +Given n pairs of parentheses, write a function to generate all +combinations of well-formed parentheses. +Input: n = 2 +Output: ["(())","()()"] +Leetcode link: https://leetcode.com/problems/generate-parentheses/description/ +""" def backtrack( partial: str, o...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/generate_parentheses.py
Add missing documentation to my Python functions
def backtrack( needed_sum: int, power: int, current_number: int, current_sum: int, solutions_count: int, ) -> tuple[int, int]: if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 return current_s...
--- +++ @@ -1,3 +1,10 @@+""" +Problem source: https://www.hackerrank.com/challenges/the-power-sum/problem +Find the number of ways that a given integer X, can be expressed as the sum +of the Nth powers of unique, natural numbers. For example, if X=13 and N=2. +We have to find all combinations of unique squares adding u...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/power_sum.py
Document my Python code with docstrings
from __future__ import annotations from typing import Any def generate_all_subsequences(sequence: list[Any]) -> None: create_state_space_tree(sequence, [], 0) def create_state_space_tree( sequence: list[Any], current_subsequence: list[Any], index: int ) -> None: if index == len(sequence): pri...
--- +++ @@ -1,3 +1,10 @@+""" +In this problem, we want to determine all possible subsequences +of the given sequence. We use backtracking to solve this problem. + +Time complexity: O(2^n), +where n denotes the length of the given sequence. +""" from __future__ import annotations @@ -11,6 +18,61 @@ def create_state...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/all_subsequences.py
Add missing documentation to my Python functions
from __future__ import annotations solution = [] def is_safe(board: list[list[int]], row: int, column: int) -> bool: n = len(board) # Size of the board # Check if there is any queen in the same upper column, # left upper diagonal and right upper diagonal return ( all(board[i][j] != 1 for ...
--- +++ @@ -1,3 +1,12 @@+""" + +The nqueens problem is of placing N queens on a N * N +chess board such that no queen can attack any other queens placed +on that chess board. +This means that one queen cannot have any other queen on its horizontal, vertical and +diagonal lines. + +""" from __future__ import annotati...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/n_queens.py
Write docstrings including parameters and return values
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter """ Create 2nd-order IIR filters with Butterworth design. Code based on https://webaudio.github.io/Audio-EQ-Cookbook/audio-eq-cookbook.html Alternatively you can use scipy.signal.butter, which should yield the same results. """ def...
--- +++ @@ -15,6 +15,14 @@ samplerate: int, q_factor: float = 1 / sqrt(2), ) -> IIRFilter: + """ + Creates a low-pass filter + + >>> filter = make_lowpass(1000, 48000) + >>> filter.a_coeffs + filter.b_coeffs # doctest: +NORMALIZE_WHITESPACE + [1.0922959556412573, -1.9828897227476208, 0.9077040...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/audio_filters/butterworth_filter.py
Create docstrings for each class method
from __future__ import annotations def generate_all_permutations(sequence: list[int | str]) -> None: create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))]) def create_state_space_tree( sequence: list[int | str], current_sequence: list[int | str], index: int, index_used: lis...
--- +++ @@ -1,3 +1,10 @@+""" +In this problem, we want to determine all possible permutations +of the given sequence. We use backtracking to solve this problem. + +Time complexity: O(n! * n), +where n denotes the length of the given sequence. +""" from __future__ import annotations @@ -12,6 +19,47 @@ index: in...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/all_permutations.py
Write docstrings that follow conventions
import string def backtrack( current_word: str, path: list[str], end_word: str, word_set: set[str] ) -> list[str]: # Base case: If the current word is the end word, return the path if current_word == end_word: return path # Try all possible single-letter transformations for i in range(l...
--- +++ @@ -1,3 +1,13 @@+""" +Word Ladder is a classic problem in computer science. +The problem is to transform a start word into an end word +by changing one letter at a time. +Each intermediate word must be a valid word from a given list of words. +The goal is to find a transformation sequence +from the start word t...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/word_ladder.py
Add docstrings for utility scripts
from __future__ import annotations from itertools import combinations def combination_lists(n: int, k: int) -> list[list[int]]: return [list(x) for x in combinations(range(1, n + 1), k)] def generate_all_combinations(n: int, k: int) -> list[list[int]]: if k < 0: raise ValueError("k must not be neg...
--- +++ @@ -1,3 +1,9 @@+""" +In this problem, we want to determine all possible combinations of k +numbers out of 1 ... n. We use backtracking to solve this problem. + +Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!))), +""" from __future__ import annotations @@ -5,10 +11,46 @@ def co...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/all_combinations.py
Insert docstrings into my code
def valid_connection( graph: list[list[int]], next_ver: int, curr_ind: int, path: list[int] ) -> bool: # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vertex is not already in path return n...
--- +++ @@ -1,8 +1,42 @@+""" +A Hamiltonian cycle (Hamiltonian circuit) is a graph cycle +through a graph that visits each node exactly once. +Determining whether such paths and cycles exist in graphs +is the 'Hamiltonian path problem', which is NP-complete. + +Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path ...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/hamiltonian_cycle.py
Create documentation for each function signature
from __future__ import annotations import math def minimax( depth: int, node_index: int, is_max: bool, scores: list[int], height: float ) -> int: if depth < 0: raise ValueError("Depth cannot be less than 0") if len(scores) == 0: raise ValueError("Scores cannot be empty") # Base cas...
--- +++ @@ -1,3 +1,12 @@+""" +Minimax helps to achieve maximum score in a game by checking all possible moves +depth is current depth in game tree. + +nodeIndex is index of current node in scores[]. +if move is of maximizer return true else false +leaves of game tree is stored in scores[] +height is maximum height of G...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/minimax.py
Document my Python code with docstrings
from __future__ import annotations def depth_first_search( possible_board: list[int], diagonal_right_collisions: list[int], diagonal_left_collisions: list[int], boards: list[list[str]], n: int, ) -> None: # Get next row in the current board (possible_board) to fill it with a queen row = ...
--- +++ @@ -1,3 +1,80 @@+r""" +Problem: + +The n queens problem is: placing N queens on a N * N chess board such that no queen +can attack any other queens placed on that chess board. This means that one queen +cannot have any other queen on its horizontal, vertical and diagonal lines. + +Solution: + +To solve this pr...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/n_queens_math.py
Turn comments into proper docstrings
from __future__ import annotations def solve_maze( maze: list[list[int]], source_row: int, source_column: int, destination_row: int, destination_column: int, ) -> list[list[int]]: size = len(maze) # Check if source and destination coordinates are Invalid. if not (0 <= source_row <= siz...
--- +++ @@ -8,6 +8,117 @@ destination_row: int, destination_column: int, ) -> list[list[int]]: + """ + This method solves the "rat in maze" problem. + Parameters : + - maze: A two dimensional matrix of zeros and ones. + - source_row: The row index of the starting point. + - sourc...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/rat_in_maze.py
Please document this code using docstrings
def get_point_key(len_board: int, len_board_column: int, row: int, column: int) -> int: return len_board * len_board_column * row + column def exits_word( board: list[list[str]], word: str, row: int, column: int, word_index: int, visited_points_set: set[int], ) -> bool: if board[ro...
--- +++ @@ -1,6 +1,45 @@+""" +Author : Alexander Pantyukhin +Date : November 24, 2022 + +Task: +Given an m x n grid of characters board and a string word, +return true if word exists in the grid. + +The word can be constructed from letters of sequentially adjacent cells, +where adjacent cells are horizontally or ve...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/word_search.py
Add docstrings to my Python code
# Knight Tour Intro: https://www.youtube.com/watch?v=ab_dY3dZFHM from __future__ import annotations def get_valid_pos(position: tuple[int, int], n: int) -> list[tuple[int, int]]: y, x = position positions = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y - 1, x - 2), ...
--- +++ @@ -4,6 +4,12 @@ def get_valid_pos(position: tuple[int, int], n: int) -> list[tuple[int, int]]: + """ + Find all the valid positions a knight can move to from the current position. + + >>> get_valid_pos((1, 3), 4) + [(2, 1), (0, 1), (3, 2)] + """ y, x = position positions = [ @@ -...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/knight_tour.py
Generate helpful docstrings for debugging
def backtrack(input_string: str, word_dict: set[str], start: int) -> bool: # Base case: if the starting index has reached the end of the string if start == len(input_string): return True # Try every possible substring from 'start' to 'end' for end in range(start + 1, len(input_string) + 1): ...
--- +++ @@ -1,6 +1,35 @@+""" +Word Break Problem is a well-known problem in computer science. +Given a string and a dictionary of words, the task is to determine if +the string can be segmented into a sequence of one or more dictionary words. + +Wikipedia: https://en.wikipedia.org/wiki/Word_break_problem +""" def ...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/word_break.py
Write docstrings including parameters and return values
from __future__ import annotations Matrix = list[list[int]] # assigning initial values to the grid initial_grid: Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, 0, 9, 0, 6, 0,...
--- +++ @@ -1,3 +1,14 @@+""" +Given a partially filled 9x9 2D array, the objective is to fill a 9x9 +square grid with digits numbered 1 to 9, so that every row, column, and +and each of the nine 3x3 sub-grids contains all of the digits. + +This can be solved using Backtracking and is similar to n-queens. +We check to s...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/sudoku.py
Add docstrings to make code maintainable
def valid_coloring( neighbours: list[int], colored_vertices: list[int], color: int ) -> bool: # Does any neighbour not satisfy the constraints return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(neighbours) ) def util_color( graph: list[l...
--- +++ @@ -1,8 +1,31 @@+""" +Graph Coloring also called "m coloring problem" +consists of coloring a given graph with at most m colors +such that no adjacent vertices are assigned the same color + +Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring +""" def valid_coloring( neighbours: list[int], colored...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/coloring.py
Generate documentation strings for clarity
def backtrack( candidates: list, path: list, answer: list, target: int, previous_index: int ) -> None: if target == 0: answer.append(path.copy()) else: for index in range(previous_index, len(candidates)): if target >= candidates[index]: path.append(candidates[in...
--- +++ @@ -1,8 +1,33 @@+""" +In the Combination Sum problem, we are given a list consisting of distinct integers. +We need to find all the combinations whose sum equals to target given. +We can use an element more than one. + +Time complexity(Average Case): O(n!) + +Constraints: +1 <= candidates.length <= 30 +2 <= can...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/combination_sum.py
Add return value explanations in docstrings
# https://www.geeksforgeeks.org/solve-crossword-puzzle/ def is_valid( puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool ) -> bool: for i in range(len(word)): if vertical: if row + i >= len(puzzle) or puzzle[row + i][col] != "": return False elif...
--- +++ @@ -4,6 +4,26 @@ def is_valid( puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool ) -> bool: + """ + Check if a word can be placed at the given position. + + >>> puzzle = [ + ... ['', '', '', ''], + ... ['', '', '', ''], + ... ['', '', '', ''], + ... ...
https://raw.githubusercontent.com/TheAlgorithms/Python/HEAD/backtracking/crossword_puzzle_solver.py
End of preview. Expand in Data Studio

Python Docstring Diff Dataset

This dataset contains training samples for models that generate Python documentation patches. Each example provides a Python source file with its docstrings removed and a corresponding unified diff patch that restores the documentation.

The dataset is designed for training or evaluating language models that assist with:

  • Automatic code documentation
  • Docstring generation
  • Code review automation
  • Developer tooling
  • Dataset Structure

Each entry contains the following fields:

Field Description

instruction| Task instruction given to the model code| Python source code with docstrings removed response| A unified diff patch that adds the correct docstrings file| Original file path from the source project

Task Format

The model receives a Python file missing its documentation and must produce a unified diff that adds appropriate docstrings.

Example input:

def load_json(path):
    with open(path) as f:
        return json.load(f)

Example expected output:

--- a/file.py
+++ b/file.py
@@
 def load_json(path):
+    """Load JSON data from a file path."""
     with open(path) as f:
         return json.load(f)

Data Sources

The dataset was generated by scanning Python packages in github. Docstrings were extracted from functions, classes, async functions, methods, and modules using Python's AST parser. Low-quality documentation was filtered out using heuristics such as:

  • Minimum docstring length
  • Removal of TODO or placeholder documentation
  • Deduplication of similar examples

Intended Use

This dataset is useful for training models that perform:

  • automatic docstring generation
  • documentation patch creation
  • codebase documentation improvement tools
  • AI-assisted code review systems

License

This dataset is released under the MIT License.

Downloads last month
30