From c57a57679d50a5ff98124da12afbc88aef172f62 Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Sat, 14 Sep 2024 03:21:06 +0900 Subject: [PATCH] Update aliases (#191) * more * more * update --- .bumpversion.cfg | 2 +- ipython/startup.py | 126 +++++++++++++++++++++++++++++++------- nvim/lazy-lock.json | 26 ++++---- nvim/lua/plugins/dial.lua | 9 ++- nvim/lua/snippets.lua | 24 +++++++- 5 files changed, 148 insertions(+), 39 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 261926b..4eccdbd 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,2 +1,2 @@ [bumpversion] -current_version = 0.1.188 +current_version = 0.1.189 diff --git a/ipython/startup.py b/ipython/startup.py index a2549c6..ee6645a 100644 --- a/ipython/startup.py +++ b/ipython/startup.py @@ -108,7 +108,16 @@ from enum import Enum, IntEnum, auto from functools import lru_cache, partial, reduce, wraps from hashlib import md5 -from inspect import signature +from inspect import ( + isasyncgen, + isasyncgenfunction, + iscoroutine, + iscoroutinefunction, + isfunction, + isgenerator, + isgeneratorfunction, + signature, +) from itertools import ( chain, count, @@ -246,6 +255,13 @@ inspect, io, is_dataclass, + isasyncgen, + isasyncgenfunction, + iscoroutine, + iscoroutinefunction, + isfunction, + isgenerator, + isgeneratorfunction, islice, it, itertools, @@ -288,7 +304,6 @@ sleep_sync, smtplib, socket, - socket, starmap, stat, statistics, @@ -430,6 +445,15 @@ _ = [cp, cvxpy] +try: + import dacite + from dacite import from_dict +except ModuleNotFoundError: + pass +else: + _ = [dacite, from_dict] + + try: from frozendict import frozendict except ModuleNotFoundError: @@ -518,15 +542,23 @@ try: from utilities.loguru import ( LogLevel, - get_logging_level, + get_logging_level_name, + get_logging_level_number, log, logged_sleep_async, logged_sleep_sync, ) except ModuleNotFoundError: - from utilities.logging import LogLevel, get_logging_level + pass else: - _ = [LogLevel, get_logging_level, log, logged_sleep_async, logged_sleep_sync] + _ = [ + LogLevel, + get_logging_level_number, + get_logging_level_name, + log, + logged_sleep_async, + logged_sleep_sync, + ] try: @@ -585,11 +617,19 @@ _ = [mi, more_itertools, partition, split_at] try: - from utilities.iterables import always_iterable, one + from utilities.iterables import ( + OneEmptyError, + OneError, + OneNonUniqueError, + always_iterable, + one, + ) except ModuleNotFoundError: from more_itertools import always_iterable, one + + _ = [always_iterable, one] else: - _ = [one, always_iterable] + _ = [OneEmptyError, OneError, OneNonUniqueError, always_iterable, one] try: from utilities.more_itertools import partition_typeguard, peekable except ModuleNotFoundError: @@ -739,6 +779,21 @@ ] +try: + import orjson +except ModuleNotFoundError: + pass +else: + _ = [orjson] + + try: + from utilities.orjson import deserialize, serialize + except ModuleNotFoundError: + pass + else: + _ = [deserialize, serialize] + + try: import pandas # noqa: ICN001 import pandas as pd @@ -992,11 +1047,27 @@ when, ] try: - from utilities.polars import check_polars_dataframe, zoned_datetime + from utilities.polars import ( + DatetimeHongKong, + DatetimeTokyo, + DatetimeUSCentral, + DatetimeUSEastern, + DatetimeUTC, + check_polars_dataframe, + zoned_datetime, + ) except ModuleNotFoundError: pass else: - _ = [check_polars_dataframe, zoned_datetime] + _ = [ + DatetimeHongKong, + DatetimeTokyo, + DatetimeUSCentral, + DatetimeUSEastern, + DatetimeUTC, + check_polars_dataframe, + zoned_datetime, + ] try: from pqdm.processes import pqdm @@ -1029,6 +1100,7 @@ else: _ = [throttle] + try: import requests except ModuleNotFoundError: @@ -1142,13 +1214,18 @@ try: + from utilities.asyncio import send_and_next_async, start_async_generator_coroutine from utilities.datetime import ( DAY, EPOCH_UTC, + HALF_YEAR, HOUR, MINUTE, + MONTH, + QUARTER, SECOND, WEEK, + YEAR, Month, date_to_datetime, ensure_month, @@ -1166,9 +1243,10 @@ serialize_month, ) from utilities.functions import get_class, get_class_name - from utilities.functools import partial + from utilities.functools import ensure_not_none, partial from utilities.git import get_repo_root from utilities.iterables import groupby_lists, one + from utilities.math import is_integral from utilities.pathlib import list_dir from utilities.pickle import read_pickle, write_pickle from utilities.random import SYSTEM_RANDOM @@ -1182,15 +1260,14 @@ ensure_datetime, ensure_float, ensure_int, - ensure_not_none, make_isinstance, ) from utilities.zoneinfo import ( - HONG_KONG, - TOKYO, - US_CENTRAL, - US_EASTERN, UTC, + HongKong, + Tokyo, + USCentral, + USEastern, get_time_zone_name, ) except ModuleNotFoundError: @@ -1200,26 +1277,32 @@ BackgroundTask, DAY, EPOCH_UTC, - HONG_KONG, + HALF_YEAR, HOUR, + HongKong, MINUTE, + MONTH, Month, + QUARTER, SECOND, SYSTEM_RANDOM, - TOKYO, Timer, - US_CENTRAL, - US_EASTERN, + Tokyo, + USCentral, + USEastern, UTC, WEEK, + YEAR, custom_print, custom_repr, date_to_datetime, + date_to_datetime, ensure_class, ensure_datetime, ensure_float, ensure_int, ensure_month, + ensure_month, ensure_not_none, ensure_str, extract_group, @@ -1239,16 +1322,17 @@ get_today_tokyo, get_years, groupby_lists, + is_integral, list_dir, make_isinstance, one, parse_month, - parse_month, partial, read_pickle, run_in_background, + send_and_next_async, serialize_month, - serialize_month, + start_async_generator_coroutine, write_pickle, ] try: diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 0322640..5fdfeaf 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -37,7 +37,7 @@ }, "conform.nvim": { "branch": "master", - "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" + "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" }, "dial.nvim": { "branch": "master", @@ -53,7 +53,7 @@ }, "fzf-lua": { "branch": "main", - "commit": "db41613292b88b5306d65caf6ae8996db5498ccb" + "commit": "985e1002b5dc70f8196ea0605bbfffc8c8407e31" }, "gitsigns.nvim": { "branch": "main", @@ -93,7 +93,7 @@ }, "luasnip": { "branch": "master", - "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" + "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, "marks.nvim": { "branch": "master", @@ -101,7 +101,7 @@ }, "mason-lspconfig.nvim": { "branch": "main", - "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" + "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, "mason-tool-installer.nvim": { "branch": "main", @@ -117,7 +117,7 @@ }, "neoscroll.nvim": { "branch": "master", - "commit": "6dfce64589e8e685d21f2dbd2df15a2473fa1d41" + "commit": "4e0428a41c6ec191df543fc95349f6e1c598e53f" }, "nvim-autopairs": { "branch": "master", @@ -145,15 +145,15 @@ }, "nvim-lint": { "branch": "master", - "commit": "a7ce9c78a7c710c28bee56dfab10a5c0c80b7fb5" + "commit": "2bb7cc049d129d7fdbf31db0bc34fad5dd216f0d" }, "nvim-lspconfig": { "branch": "master", - "commit": "bdbc65aadc708ce528efb22bca5f82a7cca6b54d" + "commit": "bb682c167a0878338b4313b55538953d1c039085" }, "nvim-neoclip.lua": { "branch": "main", - "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" + "commit": "32e05f2d23dc5b6a284a688c0535a83d1bfc633f" }, "nvim-spectre": { "branch": "master", @@ -169,11 +169,11 @@ }, "nvim-tree.lua": { "branch": "master", - "commit": "ea55ef12036897fdc4476b115a395d2a34965c82" + "commit": "d41b4ca013ed89e41b9c0ecbdae5f1633e42f7fa" }, "nvim-treesitter": { "branch": "master", - "commit": "bfe74a4899882a4ef45abb80813f14644a110a34" + "commit": "e0338f2b74fbad808f2569c7d4eadd8796af2118" }, "nvim-treesitter-context": { "branch": "master", @@ -181,7 +181,7 @@ }, "nvim-treesitter-textobjects": { "branch": "master", - "commit": "fe3deb7f67ce0cc4ebfe2ea6c1c7ae1c7a939d73" + "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" }, "nvim-various-textobjs": { "branch": "main", @@ -189,7 +189,7 @@ }, "nvim-web-devicons": { "branch": "master", - "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" + "commit": "9154484705968658e9aab2b894d1b2a64bf9f83d" }, "plenary.nvim": { "branch": "master", @@ -245,7 +245,7 @@ }, "vim-sleuth": { "branch": "master", - "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" + "commit": "cd9d382e33bb817abe7f10cdc3a606bf1d491d75" }, "vim-tmux-navigator": { "branch": "master", diff --git a/nvim/lua/plugins/dial.lua b/nvim/lua/plugins/dial.lua index 1a52271..d73349b 100644 --- a/nvim/lua/plugins/dial.lua +++ b/nvim/lua/plugins/dial.lua @@ -70,6 +70,11 @@ return { word = true, cyclic = true, }), + augend.constant.new({ + elements = { "buy", "sell" }, + word = true, + cyclic = true, + }), augend.constant.new({ elements = { "close", "open" }, word = true, @@ -101,12 +106,12 @@ return { cyclic = true, }), augend.constant.new({ - elements = { "left", "right" }, + elements = { "high", "low" }, word = true, cyclic = true, }), augend.constant.new({ - elements = { "low", "high" }, + elements = { "left", "right" }, word = true, cyclic = true, }), diff --git a/nvim/lua/snippets.lua b/nvim/lua/snippets.lua index 87737d5..44b31be 100644 --- a/nvim/lua/snippets.lua +++ b/nvim/lua/snippets.lua @@ -94,6 +94,7 @@ ls.add_snippets("python", { s("hy-phase", { t({ "from hypothesis import Phase", "" }) }), s("hy-reproduce-failure", { t({ "from hypothesis import reproduce_failure", "" }) }), s("hy-sampled-from", { t({ "from hypothesis.strategies import sampled_from", "" }) }), + s("hy-sets", { t({ "from hypothesis.strategies import sets", "" }) }), s("hy-settings", { t({ "from hypothesis import settings", "" }) }), s("hy-tuples", { t({ "from hypothesis.strategies import tuples", "" }) }), s("settings-filter-too-much", { t({ "@settings(suppress_health_check={HealthCheck.filter_too_much})", "" }) }), @@ -109,6 +110,16 @@ ls.add_snippets("python", { -- loguru s("lo-logger", { t({ "from loguru import logger", "" }) }), + s("trace-start", { t({ "logger.trace('➢')", "" }) }), + s("trace-finish", { t({ "logger.trace('✔')", "" }) }), + s("debug-start", { t({ "logger.debug('➢')", "" }) }), + s("debug-finish", { t({ "logger.debug('✔')", "" }) }), + s("info-start", { t({ "logger.info('➢')", "" }) }), + s("info-finish", { t({ "logger.info('✔')", "" }) }), + s("warning-start", { t({ "logger.warning('➢')", "" }) }), + s("warning-finish", { t({ "logger.warning('✔')", "" }) }), + s("error-start", { t({ "logger.error('➢')", "" }) }), + s("error-finish", { t({ "logger.error('✔')", "" }) }), -- math s("ma-inf", { t({ "from math import inf", "" }) }), @@ -190,7 +201,9 @@ ls.add_snippets("python", { -- re s("im-re", { t({ "import re", "" }) }), s("re-escape", { t({ "from re import escape", "" }) }), + s("re-findall", { t({ "from re import findall", "" }) }), s("re-search", { t({ "from re import search", "" }) }), + s("re-sub", { t({ "from re import sub", "" }) }), -- redis s("re-redis", { t({ "from redis import Redis", "" }) }), @@ -248,6 +261,7 @@ ls.add_snippets("python", { -- utilities s("ut-always-iterable", { t({ "from utilities.iterables import always_iterable", "" }) }), s("ut-cache", { t({ "from utilities.functools import cache", "" }) }), + s("ut-check-duplicates", { t({ "from utilities.iterables import check_duplicates", "" }) }), s("ut-check-polars-dataframe", { t({ "from utilities.polars import check_polars_dataframe", "" }) }), s("ut-custom-repr", { t({ "from utilities.reprlib import custom_repr", "" }) }), s("ut-date-to-datetime", { t({ "from utilities.datetime import date_to_datetime", "" }) }), @@ -265,7 +279,7 @@ ls.add_snippets("python", { s("ut-get-repo-root", { t({ "from utilities.git import get_repo_root", "" }) }), s("ut-get-table", { t({ "from utilities.sqlalchemy import get_table", "" }) }), s("ut-get-today", { t({ "from utilities.datetime import get_today", "" }) }), - s("ut-hong-kong", { t({ "from utilities.zoneinfo import HONG_KONG", "" }) }), + s("ut-hong-kong", { t({ "from utilities.zoneinfo import HongKong", "" }) }), s("ut-impossible-case-error", { t({ "from utilities.errors import ImpossibleCaseError", "" }) }), s("ut-index-s", { t({ "utilities.pandas import IndexS", "" }) }), s("ut-insert-dataframe", { t({ "from utilities.sqlalchemy_polars import insert_dataframe", "" }) }), @@ -276,7 +290,9 @@ ls.add_snippets("python", { s("ut-log-call", { t({ "from utilities.loguru import log_call", "" }) }), s("ut-log-level", { t({ "from utilities.loguru import LogLevel", "" }) }), s("ut-memoize", { t({ "from utilities.atools import memoize", "" }) }), + s("ut-minute", { t({ "from utilities.datetime import MINUTE", "" }) }), s("ut-one", { t({ "from utilities.iterables import one", "" }) }), + s("ut-one-empty-error", { t({ "from utilities.iterables import OneEmptyError", "" }) }), s("ut-parse-date", { t({ "from utilities.datetime import parse_date", "" }) }), s("ut-partial", { t({ "from utilities.functools import partial", "" }) }), s("ut-read-pickle", { t({ "from utilities.pickle import read_pickle", "" }) }), @@ -290,10 +306,14 @@ ls.add_snippets("python", { s("ut-temporary-directory", { t({ "from utilities.tempfile import TemporaryDirectory", "" }) }), s("ut-throttle", { t({ "from utilities.pytest import throttle", "" }) }), s("ut-timer", { t({ "from utilities.timer import Timer", "" }) }), - s("ut-tokyo", { t({ "from utilities.zoneinfo import TOKYO", "" }) }), + s("ut-tokyo", { t({ "from utilities.zoneinfo import Tokyo", "" }) }), + s("ut-transpose", { t({ "from utilities.iterables import transpose", "" }) }), + s("ut-us-central", { t({ "from utilities.zoneinfo import USCentral", "" }) }), + s("ut-us-eastern", { t({ "from utilities.zoneinfo import USEastern", "" }) }), s("ut-utc", { t({ "from utilities.zoneinfo import UTC", "" }) }), s("ut-write-pickle", { t({ "from utilities.pickle import write_pickle", "" }) }), s("ut-writer", { t({ "from utilities.atomicwrites import writer", "" }) }), + s("ut-zoned-datetime", { t({ "from utilities.polars import zoned_datetime", "" }) }), -- zoneinfo s("zo-zoneinfo", { t({ "from zoneinfo import ZoneInfo", "" }) }),