summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-30 10:22:00 +0800
committersigoden <sigoden@gmail.com>2023-10-30 10:22:00 +0800
commit44ea384ee59fafb76882e1d6687bc4cbc6d61611 (patch)
tree1ca679e0eb79b75a2e01411cb00509914bec5a23 /src
parent49595053f0a55571f42582ffae4e705c82f2aa00 (diff)
downloadaichat-44ea384ee59fafb76882e1d6687bc4cbc6d61611.tar.gz
chore: remove unnecessary clippy macros
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs1
-rw-r--r--src/client/localai.rs1
-rw-r--r--src/client/mod.rs1
-rw-r--r--src/client/openai.rs2
-rw-r--r--src/config/message.rs1
-rw-r--r--src/config/mod.rs5
-rw-r--r--src/config/session.rs1
-rw-r--r--src/render/cmd.rs1
-rw-r--r--src/render/markdown.rs3
-rw-r--r--src/render/mod.rs2
-rw-r--r--src/render/repl.rs1
-rw-r--r--src/repl/abort.rs1
-rw-r--r--src/repl/handler.rs3
-rw-r--r--src/repl/highlighter.rs1
-rw-r--r--src/repl/prompt.rs1
-rw-r--r--src/utils/tiktoken.rs2
16 files changed, 0 insertions, 27 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 91c48e8..193babb 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -1,6 +1,5 @@
use clap::Parser;
-#[allow(clippy::struct_excessive_bools, clippy::module_name_repetitions)]
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
diff --git a/src/client/localai.rs b/src/client/localai.rs
index db33480..084603b 100644
--- a/src/client/localai.rs
+++ b/src/client/localai.rs
@@ -13,7 +13,6 @@ use serde_json::json;
use std::env;
use std::time::Duration;
-#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct LocalAIClient {
global_config: SharedConfig,
diff --git a/src/client/mod.rs b/src/client/mod.rs
index b2ceb84..3397453 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -20,7 +20,6 @@ use crate::{
utils::split_text,
};
-#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Deserialize)]
#[serde(tag = "type")]
pub enum ClientConfig {
diff --git a/src/client/openai.rs b/src/client/openai.rs
index 0141d2d..4ccb1b7 100644
--- a/src/client/openai.rs
+++ b/src/client/openai.rs
@@ -16,7 +16,6 @@ use std::time::Duration;
const API_URL: &str = "https://api.openai.com/v1/chat/completions";
-#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct OpenAIClient {
global_config: SharedConfig,
@@ -24,7 +23,6 @@ pub struct OpenAIClient {
model_info: ModelInfo,
}
-#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Deserialize, Default)]
pub struct OpenAIConfig {
pub api_key: Option<String>,
diff --git a/src/config/message.rs b/src/config/message.rs
index 3c23634..d5fcff1 100644
--- a/src/config/message.rs
+++ b/src/config/message.rs
@@ -17,7 +17,6 @@ impl Message {
}
}
-#[allow(clippy::module_name_repetitions)]
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum MessageRole {
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 42521cc..4dcc2c9 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -41,7 +41,6 @@ const SET_COMPLETIONS: [&str; 7] = [
".set dry_run false",
];
-#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct Config {
@@ -105,7 +104,6 @@ impl Default for Config {
}
}
-#[allow(clippy::module_name_repetitions)]
pub type SharedConfig = Arc<RwLock<Config>>;
impl Config {
@@ -281,7 +279,6 @@ impl Config {
}
pub fn echo_messages(&self, content: &str) -> String {
- #[allow(clippy::option_if_let_else)]
if let Some(session) = self.session.as_ref() {
session.echo_messages(content)
} else if let Some(role) = self.role.as_ref() {
@@ -292,7 +289,6 @@ impl Config {
}
pub fn build_messages(&self, content: &str) -> Result<Vec<Message>> {
- #[allow(clippy::option_if_let_else)]
let messages = if let Some(session) = self.session.as_ref() {
session.build_emssages(content)
} else if let Some(role) = self.role.as_ref() {
@@ -552,7 +548,6 @@ impl Config {
}
}
- #[allow(clippy::unused_self)] // TODO: do we need to take self here? it's not used in the fn
fn open_message_file(&self) -> Result<File> {
let path = Self::messages_file()?;
ensure_parent_exists(&path)?;
diff --git a/src/config/session.rs b/src/config/session.rs
index 09fd1ff..5ecb1c2 100644
--- a/src/config/session.rs
+++ b/src/config/session.rs
@@ -110,7 +110,6 @@ impl Session {
self.tokens = num_tokens_from_messages(&self.build_emssages(""));
}
- #[allow(clippy::unnecessary_wraps)]
pub fn add_message(&mut self, input: &str, output: &str) -> Result<()> {
let mut need_add_msg = true;
if self.messages.is_empty() {
diff --git a/src/render/cmd.rs b/src/render/cmd.rs
index fb45b0a..781d376 100644
--- a/src/render/cmd.rs
+++ b/src/render/cmd.rs
@@ -7,7 +7,6 @@ use anyhow::Result;
use crossbeam::channel::Receiver;
use textwrap::core::display_width;
-#[allow(clippy::unnecessary_wraps, clippy::module_name_repetitions)]
pub fn cmd_render_stream(
rx: &Receiver<ReplyStreamEvent>,
render: &mut MarkdownRender,
diff --git a/src/render/markdown.rs b/src/render/markdown.rs
index 4866f3d..e790fa9 100644
--- a/src/render/markdown.rs
+++ b/src/render/markdown.rs
@@ -10,7 +10,6 @@ use syntect::{easy::HighlightLines, parsing::SyntaxReference};
/// Monokai Extended
const MD_THEME: &[u8] = include_bytes!("../../assets/monokai-extended.theme.bin");
const MD_THEME_LIGHT: &[u8] = include_bytes!("../../assets/monokai-extended-light.theme.bin");
-#[allow(clippy::doc_markdown)]
/// Comes from https://github.com/sharkdp/bat/raw/5e77ca37e89c873e4490b42ff556370dc5c6ba4f/assets/syntaxes.bin
const SYNTAXES: &[u8] = include_bytes!("../../assets/syntaxes.bin");
@@ -23,7 +22,6 @@ lazy_static! {
};
}
-#[allow(clippy::module_name_repetitions)]
pub struct MarkdownRender {
options: RenderOptions,
syntax_set: SyntaxSet,
@@ -197,7 +195,6 @@ impl MarkdownRender {
}
fn find_syntax(&self, lang: &str) -> Option<&SyntaxReference> {
- #[allow(clippy::option_if_let_else)]
if let Some(new_lang) = LANGE_MAPS.get(&lang.to_ascii_lowercase()) {
self.syntax_set.find_syntax_by_name(new_lang)
} else {
diff --git a/src/render/mod.rs b/src/render/mod.rs
index 9d7b06a..2d4cbfb 100644
--- a/src/render/mod.rs
+++ b/src/render/mod.rs
@@ -3,7 +3,6 @@ mod markdown;
mod repl;
use self::cmd::cmd_render_stream;
-#[allow(clippy::module_name_repetitions)]
pub use self::markdown::{MarkdownRender, RenderOptions};
use self::repl::repl_render_stream;
@@ -17,7 +16,6 @@ use crossbeam::channel::unbounded;
use crossbeam::sync::WaitGroup;
use std::thread::spawn;
-#[allow(clippy::module_name_repetitions)]
pub fn render_stream(
input: &str,
client: &dyn Client,
diff --git a/src/render/repl.rs b/src/render/repl.rs
index c411670..bbc0d2c 100644
--- a/src/render/repl.rs
+++ b/src/render/repl.rs
@@ -16,7 +16,6 @@ use std::{
};
use textwrap::core::display_width;
-#[allow(clippy::module_name_repetitions)]
pub fn repl_render_stream(
rx: &Receiver<ReplyStreamEvent>,
render: &mut MarkdownRender,
diff --git a/src/repl/abort.rs b/src/repl/abort.rs
index 5377f43..f76abb6 100644
--- a/src/repl/abort.rs
+++ b/src/repl/abort.rs
@@ -5,7 +5,6 @@ use std::sync::{
pub type SharedAbortSignal = Arc<AbortSignal>;
-#[allow(clippy::module_name_repetitions)]
pub struct AbortSignal {
ctrlc: AtomicBool,
ctrld: AtomicBool,
diff --git a/src/repl/handler.rs b/src/repl/handler.rs
index 35a57da..bafad14 100644
--- a/src/repl/handler.rs
+++ b/src/repl/handler.rs
@@ -27,7 +27,6 @@ pub enum ReplCmd {
ReadFile(String),
}
-#[allow(clippy::module_name_repetitions)]
pub struct ReplCmdHandler {
config: SharedConfig,
abort: SharedAbortSignal,
@@ -35,7 +34,6 @@ pub struct ReplCmdHandler {
}
impl ReplCmdHandler {
- #[allow(clippy::unnecessary_wraps)]
pub fn init(config: SharedConfig, abort: SharedAbortSignal) -> Result<Self> {
let clipboard = Clipboard::new().map(RefCell::new);
Ok(Self {
@@ -135,7 +133,6 @@ impl ReplCmdHandler {
}
}
-#[allow(clippy::module_name_repetitions)]
pub struct ReplyStreamHandler {
sender: Sender<ReplyStreamEvent>,
buffer: String,
diff --git a/src/repl/highlighter.rs b/src/repl/highlighter.rs
index b1ec023..103d198 100644
--- a/src/repl/highlighter.rs
+++ b/src/repl/highlighter.rs
@@ -5,7 +5,6 @@ use reedline::{Highlighter, StyledText};
const MATCH_COLOR: Color = Color::Green;
-#[allow(clippy::module_name_repetitions)]
pub struct ReplHighlighter {
external_commands: Vec<String>,
config: SharedConfig,
diff --git a/src/repl/prompt.rs b/src/repl/prompt.rs
index f48ce64..94b7123 100644
--- a/src/repl/prompt.rs
+++ b/src/repl/prompt.rs
@@ -9,7 +9,6 @@ const PROMPT_MULTILINE_COLOR: nu_ansi_term::Color = nu_ansi_term::Color::LightBl
const INDICATOR_COLOR: Color = Color::Cyan;
const PROMPT_RIGHT_COLOR: Color = Color::AnsiValue(5);
-#[allow(clippy::module_name_repetitions)]
#[derive(Clone)]
pub struct ReplPrompt {
config: SharedConfig,
diff --git a/src/utils/tiktoken.rs b/src/utils/tiktoken.rs
index 940d6f9..ce47c17 100644
--- a/src/utils/tiktoken.rs
+++ b/src/utils/tiktoken.rs
@@ -64,7 +64,6 @@ pub fn cl100k_base_singleton() -> Arc<Mutex<CoreBPE>> {
}
fn _byte_pair_merge(piece: &[u8], ranks: &HashMap<Vec<u8>, usize>) -> Vec<std::ops::Range<usize>> {
- #[allow(clippy::range_plus_one)]
let mut parts: Vec<_> = (0..piece.len()).map(|i| i..i + 1).collect();
// If you have n parts and m merges, this does O(mn) work
@@ -340,7 +339,6 @@ impl CoreBPE {
&& self.sorted_token_bytes[point].starts_with(suffix)
{
let possibility = [prefix, self.sorted_token_bytes[point].as_slice()].concat();
- #[allow(clippy::option_if_let_else)]
let encoded = match std::str::from_utf8(&possibility) {
// Morally, this is byte_pair_encode(&possibility, &self.encoder)
// But we might have introduced a regex split which would prevent merges.