Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] auto-fix prefer Self over explicit type #2908

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
impl PyDaftPlanningConfig {
#[new]
pub fn new() -> Self {
PyDaftPlanningConfig::default()
Self::default()

Check warning on line 20 in src/common/daft-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/daft-config/src/python.rs#L20

Added line #L20 was not covered by tests
}

#[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> {

Check warning on line 30 in src/common/daft-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/daft-config/src/python.rs#L30

Added line #L30 was not covered by tests
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 {

Check warning on line 37 in src/common/daft-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/daft-config/src/python.rs#L37

Added line #L37 was not covered by tests
config: Arc::new(config),
})
}
Expand Down Expand Up @@ -67,12 +64,12 @@
impl PyDaftExecutionConfig {
#[new]
pub fn new() -> Self {
PyDaftExecutionConfig::default()
Self::default()

Check warning on line 67 in src/common/daft-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/daft-config/src/python.rs#L67

Added line #L67 was not covered by tests
}

#[staticmethod]
pub fn from_env() -> Self {
PyDaftExecutionConfig {
Self {
config: Arc::new(DaftExecutionConfig::from_env()),
}
}
Expand All @@ -98,7 +95,7 @@
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 @@
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 @@

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 HTTPConfig {
pub fn new<S: Into<ObfuscatedString>>(bearer_token: Option<S>) -> Self {
HTTPConfig {
Self {

Check warning on line 24 in src/common/io-config/src/http.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/http.rs#L24

Added line #L24 was not covered by tests
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 @@
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(ObfuscatedString(s.into()))
Ok(Self(s.into()))

Check warning on line 76 in src/common/io-config/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/lib.rs#L76

Added line #L76 was not covered by tests
}
}

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 @@
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 @@
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 @@
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 @@
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 @@
})
.transpose()?;

Ok(S3Credentials {
Ok(Self {
credentials: crate::S3Credentials {
key_id,
access_key,
Expand Down Expand Up @@ -606,7 +606,7 @@
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 @@
use_ssl: Option<bool>,
) -> Self {
let def = crate::AzureConfig::default();
AzureConfig {
Self {

Check warning on line 696 in src/common/io-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/python.rs#L696

Added line #L696 was not covered by tests
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 @@
endpoint_url: Option<String>,
use_ssl: Option<bool>,
) -> Self {
AzureConfig {
Self {

Check warning on line 728 in src/common/io-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/python.rs#L728

Added line #L728 was not covered by tests
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 @@
anonymous: Option<bool>,
) -> Self {
let def = crate::GCSConfig::default();
GCSConfig {
Self {

Check warning on line 838 in src/common/io-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/python.rs#L838

Added line #L838 was not covered by tests
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 @@
token: Option<String>,
anonymous: Option<bool>,
) -> Self {
GCSConfig {
Self {

Check warning on line 855 in src/common/io-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/python.rs#L855

Added line #L855 was not covered by tests
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 HTTPConfig {
#[new]
pub fn new(bearer_token: Option<String>) -> Self {
HTTPConfig {
Self {

Check warning on line 910 in src/common/io-config/src/python.rs

View check run for this annotation

Codecov / codecov/patch

src/common/io-config/src/python.rs#L910

Added line #L910 was not covered by tests
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 @@
///
/// 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 {

Check warning on line 88 in src/common/resource-request/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/common/resource-request/src/lib.rs#L88

Added line #L88 was not covered by tests
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 @@
}
}

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 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 @@
}

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
Loading