Skip to content

Commit

Permalink
Improve Rust correctness and linting
Browse files Browse the repository at this point in the history
- Introduce crate-level deny attributes
- Enforce stricter rustc and clippy lints
- Prune and tidy crate dependencies
  • Loading branch information
cjdsellers committed Jan 22, 2025
1 parent d1764a3 commit d236d50
Show file tree
Hide file tree
Showing 50 changed files with 794 additions and 687 deletions.
20 changes: 0 additions & 20 deletions nautilus_core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions nautilus_core/adapters/databento/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ path = "bin/sandbox.rs"
[dependencies]
nautilus-core = { path = "../../core" }
nautilus-model = { path = "../../model" }
nautilus-serialization = { path = "../../serialization" }
anyhow = { workspace = true }
indexmap = { workspace = true }
itoa = { workspace = true }
Expand All @@ -27,7 +26,6 @@ pyo3-async-runtimes = { workspace = true, optional = true }
serde = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
ustr = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions nautilus_core/adapters/databento/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

//! The [Databento](https://databento.com) integration adapter.
#![deny(warnings)]
#![deny(nonstandard_style)]
#![deny(missing_debug_implementations)]
#![deny(rustdoc::broken_intra_doc_links)]
// #![deny(clippy::missing_errors_doc)]

pub mod common;
pub mod decode;
pub mod enums;
Expand Down
1 change: 1 addition & 0 deletions nautilus_core/adapters/databento/src/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub enum LiveMessage {
/// [`LiveCommand`] messages are recieved synchronously across a channel,
/// decoded records are sent asynchronously on a tokio channel as [`LiveMessage`]s
/// back to a message processing task.
#[derive(Debug)]
pub struct DatabentoFeedHandler {
key: String,
dataset: String,
Expand Down
1 change: 1 addition & 0 deletions nautilus_core/adapters/databento/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ use super::{
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Debug)]
pub struct DatabentoDataLoader {
publishers_map: IndexMap<PublisherId, DatabentoPublisher>,
venue_dataset_map: IndexMap<Venue, Dataset>,
Expand Down
1 change: 1 addition & 0 deletions nautilus_core/adapters/databento/src/python/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ use crate::{
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Debug)]
pub struct DatabentoHistoricalClient {
#[pyo3(get)]
pub key: String,
Expand Down
1 change: 1 addition & 0 deletions nautilus_core/adapters/databento/src/python/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::{
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.databento")
)]
#[derive(Debug)]
pub struct DatabentoLiveClient {
#[pyo3(get)]
pub key: String,
Expand Down
1 change: 0 additions & 1 deletion nautilus_core/adapters/tardis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async-stream = { workspace = true }
chrono = { workspace = true }
futures-util = { workspace = true }
heck = { workspace = true }
parquet = { workspace = true }
pyo3 = { workspace = true, optional = true }
pyo3-async-runtimes = { workspace = true, optional = true }
reqwest = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions nautilus_core/adapters/tardis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@

//! The [Tardis](https://tardis.dev) integration adapter.
#![deny(unsafe_code)]
#![deny(warnings)]
#![deny(nonstandard_style)]
#![deny(missing_debug_implementations)]
#![deny(rustdoc::broken_intra_doc_links)]
// #![deny(clippy::missing_errors_doc)]

pub mod config;
pub mod csv;
pub mod enums;
Expand Down
7 changes: 7 additions & 0 deletions nautilus_core/analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
//! - `ffi`: Enables the C foreign function interface (FFI) from `cbindgen`.
//! - `python`: Enables Python bindings from `pyo3`.
#![deny(unsafe_code)]
#![deny(warnings)]
#![deny(nonstandard_style)]
#![deny(missing_debug_implementations)]
#![deny(rustdoc::broken_intra_doc_links)]
// #![deny(clippy::missing_errors_doc)]

pub mod analyzer;
pub mod statistic;
pub mod statistics;
Expand Down
8 changes: 8 additions & 0 deletions nautilus_core/backtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
//! - `ffi`: Enables the C foreign function interface (FFI) from `cbindgen`.
//! - `python`: Enables Python bindings from `pyo3`.
#![deny(warnings)]
#![deny(nonstandard_style)]
#![deny(rustdoc::broken_intra_doc_links)]
// #![deny(clippy::missing_errors_doc)]

// Uncomment once we've added trivial `Debug` impls everywhere
// #![warn(missing_debug_implementations)]

pub mod data_client;
pub mod engine;
pub mod exchange;
Expand Down
5 changes: 5 additions & 0 deletions nautilus_core/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
// limitations under the License.
// -------------------------------------------------------------------------------------------------

#![deny(unsafe_code)]
#![deny(warnings)]
#![deny(nonstandard_style)]
#![deny(missing_debug_implementations)]

mod database;
pub mod opt;

Expand Down
2 changes: 1 addition & 1 deletion nautilus_core/cli/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use clap::Parser;

#[derive(Parser)]
#[derive(Debug, Parser)]
#[clap(version, about, author)]
pub struct NautilusCli {
#[clap(subcommand)]
Expand Down
3 changes: 1 addition & 2 deletions nautilus_core/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ indexmap = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
pyo3 = { workspace = true, optional = true }
pyo3-async-runtimes = { workspace = true, optional = true }
rstest = { workspace = true , optional = true }
rust_decimal = { workspace = true }
rust_decimal_macros = { workspace = true }
Expand Down Expand Up @@ -52,4 +51,4 @@ extension-module = [
]
ffi = ["cbindgen", "nautilus-core/ffi", "nautilus-model/ffi"]
"clock_v2" = []
python = ["pyo3", "pyo3-async-runtimes", "nautilus-core/python", "nautilus-model/python"]
python = ["pyo3", "nautilus-core/python", "nautilus-model/python"]
1 change: 1 addition & 0 deletions nautilus_core/common/src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl CacheConfig {
}

/// A key-value lookup index for a `Cache`.
#[derive(Debug)]
pub struct CacheIndex {
venue_account: HashMap<Venue, AccountId>,
venue_orders: HashMap<Venue, HashSet<ClientOrderId>>,
Expand Down
Loading

0 comments on commit d236d50

Please sign in to comment.