This document provides guidelines for maintaining high-quality Python code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
| import pytest | |
| from unittest.mock import AsyncMock, MagicMock | |
| from motor.motor_asyncio import AsyncIOMotorClient | |
| # Example function to test | |
| async def get_data_from_collection(db_client, collection_name, query): | |
| collection = db_client["test_database"][collection_name] | |
| result = await collection.find_one(query) | |
| return result |
| function getId() { | |
| /** | |
| * Imported from https://github.com/kyo-ago/UUID | |
| * Robbie Mitchell, @superstrong | |
| */ | |
| /** | |
| * UUID.core.js: The minimal subset of the RFC-compliant UUID generator UUID.js. | |
| * | |
| * @fileOverview |
| <div class="menu-btn"> | |
| <i class="fas fa-bars fa-2x"></i> | |
| </div> | |
| <div class="container"> | |
| <!-- Nav --> | |
| <nav class="main-nav"> | |
| <img src="https://i.ibb.co/wwLhz98/logo.png" alt="Microsoft" class="logo"> | |
| <ul class="main-menu"> |
| moment.min.js | |
| moment-timezone-with-data-2010-2020.min.js |
| from datetime import timedelta, date | |
| def daterange(date1, date2): | |
| for n in range(int ((date2 - date1).days)+1): | |
| yield date1 + timedelta(n) | |
| start_dt = date(2015, 12, 20) | |
| end_dt = date(2016, 1, 11) | |
| for dt in daterange(start_dt, end_dt): | |
| print(dt.strftime("%Y-%m-%d")) |
| from pymongo import Connection | |
| from bson import ObjectId | |
| from itertools import imap | |
| class Model(dict): | |
| """ | |
| A simple model that wraps mongodb document | |
| """ | |
| __getattr__ = dict.get |
| function myFunction() { | |
| var ss = SpreadsheetApp.getActive(); | |
| var sheet = ss.getSheetByName("orange"); | |
| var range = sheet.getRange("1:1").getValues(); | |
| var titles = range[0]; | |
| var a1range = "A1:A"; | |
| var a1array = []; | |
| a1range = a1range +titles.length*titles.length; | |
| var b1range = "B1:B"; |
| // http://stackoverflow.com/questions/11273268/script-import-local-csv-in-google-spreadsheet | |
| function onOpen() { | |
| var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
| var csvMenuEntries = [{name: "Upload CSV file", functionName: "doGet"}]; | |
| ss.addMenu("CSV", csvMenuEntries); | |
| } | |
| function doGet(e) { | |
| var app = UiApp.createApplication().setTitle("Upload CSV to Sheet"); |
| import org.json.JSONObject | |
| import org.json.JSONArray | |
| class Task(val title:String, val email:String, val description:String) { | |
| fun convertToJSON(): JSONObject { | |
| val json = JSONObject() | |
| json.put("title", title) | |
| json.put("email", email) | |
| json.put("description", description) | |
| return json |