Skip to content

Commit

Permalink
[CHORE] auto-fix prefer Self over explicit type (#2908)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka authored Sep 25, 2024
1 parent d57433a commit 45e2944
Show file tree
Hide file tree
Showing 209 changed files with 1,205 additions and 1,331 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ version = "0.11.0"
features = ["derive", "rc"]
version = "1.0.200"

[workspace.lints.clippy]
use-self = "deny"

[workspace.package]
edition = "2021"
version = "0.3.0-dev0"
3 changes: 3 additions & 0 deletions src/common/arrow-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pyo3 = {workspace = true, optional = true}
[features]
python = ["dep:pyo3"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-arrow-ffi"
Expand Down
3 changes: 3 additions & 0 deletions src/common/daft-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ serde = {workspace = true}
[features]
python = ["dep:pyo3", "common-io-config/python"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-daft-config"
Expand Down
2 changes: 1 addition & 1 deletion src/common/daft-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct DaftExecutionConfig {

impl Default for DaftExecutionConfig {
fn default() -> Self {
DaftExecutionConfig {
Self {
scan_tasks_min_size_bytes: 96 * 1024 * 1024, // 96MB
scan_tasks_max_size_bytes: 384 * 1024 * 1024, // 384MB
broadcast_join_size_bytes_threshold: 10 * 1024 * 1024, // 10 MiB
Expand Down
19 changes: 8 additions & 11 deletions src/common/daft-config/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,24 @@ pub struct PyDaftPlanningConfig {
impl PyDaftPlanningConfig {
#[new]
pub fn new() -> Self {
PyDaftPlanningConfig::default()
Self::default()
}

#[staticmethod]
pub fn from_env() -> Self {
PyDaftPlanningConfig {
Self {
config: Arc::new(DaftPlanningConfig::from_env()),
}
}

fn with_config_values(
&mut self,
default_io_config: Option<PyIOConfig>,
) -> PyResult<PyDaftPlanningConfig> {
fn with_config_values(&mut self, default_io_config: Option<PyIOConfig>) -> PyResult<Self> {
let mut config = self.config.as_ref().clone();

if let Some(default_io_config) = default_io_config {
config.default_io_config = default_io_config.config;
}

Ok(PyDaftPlanningConfig {
Ok(Self {
config: Arc::new(config),
})
}
Expand Down Expand Up @@ -67,12 +64,12 @@ pub struct PyDaftExecutionConfig {
impl PyDaftExecutionConfig {
#[new]
pub fn new() -> Self {
PyDaftExecutionConfig::default()
Self::default()
}

#[staticmethod]
pub fn from_env() -> Self {
PyDaftExecutionConfig {
Self {
config: Arc::new(DaftExecutionConfig::from_env()),
}
}
Expand All @@ -98,7 +95,7 @@ impl PyDaftExecutionConfig {
enable_aqe: Option<bool>,
enable_native_executor: Option<bool>,
default_morsel_size: Option<usize>,
) -> PyResult<PyDaftExecutionConfig> {
) -> PyResult<Self> {
let mut config = self.config.as_ref().clone();

if let Some(scan_tasks_max_size_bytes) = scan_tasks_max_size_bytes {
Expand Down Expand Up @@ -161,7 +158,7 @@ impl PyDaftExecutionConfig {
config.default_morsel_size = default_morsel_size;
}

Ok(PyDaftExecutionConfig {
Ok(Self {
config: Arc::new(config),
})
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ textwrap = {version = "0.16.1"}
[features]
python = ["dep:pyo3"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-display"
Expand Down
3 changes: 3 additions & 0 deletions src/common/error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ thiserror = {workspace = true}
[features]
python = ["dep:pyo3"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-error"
Expand Down
2 changes: 1 addition & 1 deletion src/common/error/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import_exception!(daft.exceptions, ByteStreamError);
import_exception!(daft.exceptions, SocketError);

impl std::convert::From<DaftError> for pyo3::PyErr {
fn from(err: DaftError) -> pyo3::PyErr {
fn from(err: DaftError) -> Self {
match err {
DaftError::PyO3Error(pyerr) => pyerr,
DaftError::FileNotFound { path, source } => {
Expand Down
3 changes: 3 additions & 0 deletions src/common/file-formats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ serde_json = {workspace = true, optional = true}
[features]
python = ["dep:pyo3", "dep:serde_json", "common-error/python", "common-py-serde/python", "daft-schema/python"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-file-formats"
Expand Down
3 changes: 3 additions & 0 deletions src/common/hashable-float-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[dependencies]
serde = {workspace = true}

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-hashable-float-wrapper"
Expand Down
3 changes: 3 additions & 0 deletions src/common/io-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ typetag = "0.2.16"
[features]
python = ["dep:pyo3", "common-error/python", "common-py-serde/python"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-io-config"
Expand Down
4 changes: 2 additions & 2 deletions src/common/io-config/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct HTTPConfig {

impl Default for HTTPConfig {
fn default() -> Self {
HTTPConfig {
Self {
user_agent: "daft/0.0.1".to_string(), // NOTE: Ideally we grab the version of Daft, but that requires a dependency on daft-core
bearer_token: None,
}
Expand All @@ -21,7 +21,7 @@ impl Default for HTTPConfig {

impl HTTPConfig {
pub fn new<S: Into<ObfuscatedString>>(bearer_token: Option<S>) -> Self {
HTTPConfig {
Self {
bearer_token: bearer_token.map(|t| t.into()),
..Default::default()
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/io-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ impl<'de> Deserialize<'de> for ObfuscatedString {
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(ObfuscatedString(s.into()))
Ok(Self(s.into()))
}
}

impl From<String> for ObfuscatedString {
fn from(value: String) -> Self {
ObfuscatedString(value.into())
Self(value.into())
}
}
22 changes: 11 additions & 11 deletions src/common/io-config/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl IOConfig {
gcs: Option<GCSConfig>,
http: Option<HTTPConfig>,
) -> Self {
IOConfig {
Self {
config: config::IOConfig {
s3: s3.unwrap_or_default().config,
azure: azure.unwrap_or_default().config,
Expand All @@ -171,7 +171,7 @@ impl IOConfig {
gcs: Option<GCSConfig>,
http: Option<HTTPConfig>,
) -> Self {
IOConfig {
Self {
config: config::IOConfig {
s3: s3.map(|s3| s3.config).unwrap_or(self.config.s3.clone()),
azure: azure
Expand Down Expand Up @@ -274,7 +274,7 @@ impl S3Config {
profile_name: Option<String>,
) -> PyResult<Self> {
let def = crate::S3Config::default();
Ok(S3Config {
Ok(Self {
config: crate::S3Config {
region_name: region_name.or(def.region_name),
endpoint_url: endpoint_url.or(def.endpoint_url),
Expand Down Expand Up @@ -333,7 +333,7 @@ impl S3Config {
force_virtual_addressing: Option<bool>,
profile_name: Option<String>,
) -> PyResult<Self> {
Ok(S3Config {
Ok(Self {
config: crate::S3Config {
region_name: region_name.or_else(|| self.config.region_name.clone()),
endpoint_url: endpoint_url.or_else(|| self.config.endpoint_url.clone()),
Expand Down Expand Up @@ -545,7 +545,7 @@ impl S3Credentials {
})
.transpose()?;

Ok(S3Credentials {
Ok(Self {
credentials: crate::S3Credentials {
key_id,
access_key,
Expand Down Expand Up @@ -606,7 +606,7 @@ pub struct PyS3CredentialsProvider {
impl PyS3CredentialsProvider {
pub fn new(provider: Bound<PyAny>) -> PyResult<Self> {
let hash = provider.hash()?;
Ok(PyS3CredentialsProvider {
Ok(Self {
provider: provider.into(),
hash,
})
Expand Down Expand Up @@ -693,7 +693,7 @@ impl AzureConfig {
use_ssl: Option<bool>,
) -> Self {
let def = crate::AzureConfig::default();
AzureConfig {
Self {
config: crate::AzureConfig {
storage_account: storage_account.or(def.storage_account),
access_key: access_key.map(|v| v.into()).or(def.access_key),
Expand Down Expand Up @@ -725,7 +725,7 @@ impl AzureConfig {
endpoint_url: Option<String>,
use_ssl: Option<bool>,
) -> Self {
AzureConfig {
Self {
config: crate::AzureConfig {
storage_account: storage_account.or_else(|| self.config.storage_account.clone()),
access_key: access_key
Expand Down Expand Up @@ -835,7 +835,7 @@ impl GCSConfig {
anonymous: Option<bool>,
) -> Self {
let def = crate::GCSConfig::default();
GCSConfig {
Self {
config: crate::GCSConfig {
project_id: project_id.or(def.project_id),
credentials: credentials.map(|v| v.into()).or(def.credentials),
Expand All @@ -852,7 +852,7 @@ impl GCSConfig {
token: Option<String>,
anonymous: Option<bool>,
) -> Self {
GCSConfig {
Self {
config: crate::GCSConfig {
project_id: project_id.or_else(|| self.config.project_id.clone()),
credentials: credentials
Expand Down Expand Up @@ -907,7 +907,7 @@ impl From<config::IOConfig> for IOConfig {
impl HTTPConfig {
#[new]
pub fn new(bearer_token: Option<String>) -> Self {
HTTPConfig {
Self {
config: crate::HTTPConfig::new(bearer_token),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/io-config/src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl S3Config {

impl Default for S3Config {
fn default() -> Self {
S3Config {
Self {
region_name: None,
endpoint_url: None,
key_id: None,
Expand Down
3 changes: 3 additions & 0 deletions src/common/py-serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ serde = {workspace = true}
[features]
python = ["dep:pyo3"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-py-serde"
Expand Down
3 changes: 3 additions & 0 deletions src/common/resource-request/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ serde = {workspace = true}
[features]
python = ["dep:pyo3", "common-py-serde/python"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-resource-request"
Expand Down
14 changes: 7 additions & 7 deletions src/common/resource-request/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl ResourceRequest {
///
/// Currently, this returns true unless one resource request has a non-zero CPU request and the other task has a
/// non-zero GPU request.
pub fn is_pipeline_compatible_with(&self, other: &ResourceRequest) -> bool {
pub fn is_pipeline_compatible_with(&self, other: &Self) -> bool {
let self_num_cpus = self.num_cpus;
let self_num_gpus = self.num_gpus;
let other_num_cpus = other.num_cpus;
Expand All @@ -100,7 +100,7 @@ impl ResourceRequest {
}
}

pub fn max(&self, other: &ResourceRequest) -> Self {
pub fn max(&self, other: &Self) -> Self {
let max_num_cpus = lift(float_max, self.num_cpus, other.num_cpus);
let max_num_gpus = lift(float_max, self.num_gpus, other.num_gpus);
let max_memory_bytes = lift(std::cmp::max, self.memory_bytes, other.memory_bytes);
Expand Down Expand Up @@ -152,8 +152,8 @@ impl Hash for ResourceRequest {
}
}

impl AsRef<ResourceRequest> for ResourceRequest {
fn as_ref(&self) -> &ResourceRequest {
impl AsRef<Self> for ResourceRequest {
fn as_ref(&self) -> &Self {
self
}
}
Expand Down Expand Up @@ -200,21 +200,21 @@ impl ResourceRequest {
}

pub fn with_num_cpus(&self, num_cpus: Option<f64>) -> Self {
ResourceRequest {
Self {
num_cpus,
..self.clone()
}
}

pub fn with_num_gpus(&self, num_gpus: Option<f64>) -> Self {
ResourceRequest {
Self {
num_gpus,
..self.clone()
}
}

pub fn with_memory_bytes(&self, memory_bytes: Option<usize>) -> Self {
ResourceRequest {
Self {
memory_bytes,
..self.clone()
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/system-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ sysinfo = "0.30.7"
[features]
python = ["dep:pyo3"]

[lints]
workspace = true

[package]
edition = {workspace = true}
name = "common-system-info"
Expand Down
2 changes: 1 addition & 1 deletion src/common/system-info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct SystemInfo {

impl Default for SystemInfo {
fn default() -> Self {
SystemInfo {
Self {
info: sysinfo::System::new_with_specifics(
RefreshKind::new()
.with_cpu(CpuRefreshKind::everything())
Expand Down
Loading

0 comments on commit 45e2944

Please sign in to comment.