From 04f5e59ec20fd0d0a1e2f95f4ae03e720505c53f Mon Sep 17 00:00:00 2001 From: trag1c Date: Fri, 9 Feb 2024 21:47:07 +0100 Subject: [PATCH] =?UTF-8?q?Corrected=20PTH203=E2=80=93PTH205=20rule=20desc?= =?UTF-8?q?riptions=20(#9914)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Closes #9898. ## Test Plan ```sh python scripts/generate_mkdocs.py && mkdocs serve -f mkdocs.public.yml ``` --- .../rules/flake8_use_pathlib/rules/os_path_getatime.rs | 8 ++++---- .../rules/flake8_use_pathlib/rules/os_path_getctime.rs | 10 +++++----- .../rules/flake8_use_pathlib/rules/os_path_getmtime.rs | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs index 77f0c14925d3d..965a35ab8cc0d 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs @@ -10,7 +10,7 @@ use ruff_macros::{derive_message_formats, violation}; /// /// When possible, using `Path` object methods such as `Path.stat()` can /// improve readability over the `os` module's counterparts (e.g., -/// `os.path.getsize()`). +/// `os.path.getatime()`). /// /// Note that `os` functions may be preferable if performance is a concern, /// e.g., in hot loops. @@ -19,19 +19,19 @@ use ruff_macros::{derive_message_formats, violation}; /// ```python /// import os /// -/// os.path.getsize(__file__) +/// os.path.getatime(__file__) /// ``` /// /// Use instead: /// ```python /// from pathlib import Path /// -/// Path(__file__).stat().st_size +/// Path(__file__).stat().st_atime /// ``` /// /// ## References /// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat) -/// - [Python documentation: `os.path.getsize`](https://docs.python.org/3/library/os.path.html#os.path.getsize) +/// - [Python documentation: `os.path.getatime`](https://docs.python.org/3/library/os.path.html#os.path.getatime) /// - [PEP 428](https://peps.python.org/pep-0428/) /// - [Correspondence between `os` and `pathlib`](https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module) /// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs index ec9c3fffab0c5..d8b8e186e92a6 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs @@ -2,7 +2,7 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; /// ## What it does -/// Checks for uses of `os.path.getatime`. +/// Checks for uses of `os.path.getctime`. /// /// ## Why is this bad? /// `pathlib` offers a high-level API for path manipulation, as compared to @@ -10,7 +10,7 @@ use ruff_macros::{derive_message_formats, violation}; /// /// When possible, using `Path` object methods such as `Path.stat()` can /// improve readability over the `os` module's counterparts (e.g., -/// `os.path.getsize()`). +/// `os.path.getctime()`). /// /// Note that `os` functions may be preferable if performance is a concern, /// e.g., in hot loops. @@ -19,19 +19,19 @@ use ruff_macros::{derive_message_formats, violation}; /// ```python /// import os /// -/// os.path.getsize(__file__) +/// os.path.getctime(__file__) /// ``` /// /// Use instead: /// ```python /// from pathlib import Path /// -/// Path(__file__).stat().st_size +/// Path(__file__).stat().st_ctime /// ``` /// /// ## References /// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat) -/// - [Python documentation: `os.path.getsize`](https://docs.python.org/3/library/os.path.html#os.path.getsize) +/// - [Python documentation: `os.path.getctime`](https://docs.python.org/3/library/os.path.html#os.path.getctime) /// - [PEP 428](https://peps.python.org/pep-0428/) /// - [Correspondence between `os` and `pathlib`](https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module) /// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs index ae3249af6f0aa..03f74e7b11b54 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs @@ -2,7 +2,7 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; /// ## What it does -/// Checks for uses of `os.path.getatime`. +/// Checks for uses of `os.path.getmtime`. /// /// ## Why is this bad? /// `pathlib` offers a high-level API for path manipulation, as compared to @@ -10,7 +10,7 @@ use ruff_macros::{derive_message_formats, violation}; /// /// When possible, using `Path` object methods such as `Path.stat()` can /// improve readability over the `os` module's counterparts (e.g., -/// `os.path.getsize()`). +/// `os.path.getmtime()`). /// /// Note that `os` functions may be preferable if performance is a concern, /// e.g., in hot loops. @@ -19,19 +19,19 @@ use ruff_macros::{derive_message_formats, violation}; /// ```python /// import os /// -/// os.path.getsize(__file__) +/// os.path.getmtime(__file__) /// ``` /// /// Use instead: /// ```python /// from pathlib import Path /// -/// Path(__file__).stat().st_size +/// Path(__file__).stat().st_mtime /// ``` /// /// ## References /// - [Python documentation: `Path.stat`](https://docs.python.org/3/library/pathlib.html#pathlib.Path.stat) -/// - [Python documentation: `os.path.getsize`](https://docs.python.org/3/library/os.path.html#os.path.getsize) +/// - [Python documentation: `os.path.getmtime`](https://docs.python.org/3/library/os.path.html#os.path.getmtime) /// - [PEP 428](https://peps.python.org/pep-0428/) /// - [Correspondence between `os` and `pathlib`](https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module) /// - [Why you should be using pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/)