تصویر بذریعہ ایڈیٹر
رف is an extremely fast Python linter and formatter written in Rust that aims to replace and improve upon existing tools like Flake8, Black, and isort. It provides 10-100x faster performance while maintaining parity through over 700 built-in rules and reimplementation of popular plugins.
Stats from Ruff | Linting the CPython codebase from scratch
Ruff supports modern Python with 3.12 compatibility and `pyproject.toml`. It also offers automatic fix support, caching, and editor integrations. Ruff is monorepo-friendly and used in major open-source projects like Pandas, FastAPI, and more. By combining speed, functionality, and usability, Ruff integrates linting, formatting, and automatic fixing in a unified tool that is orders of magnitude faster than existing options.
We can easily install `ruff` by using PIP.
pip install ruff
To test how easy and fast it is to run Ruff, we can use the DagHub repository kingabzpro/Yoga-Pose-Classification. You can clone it or use your own project to format.
پروجیکٹ کی ساخت
First, we will run a linter over our project. You can also run linter on a single file by replacing “.” with file location.
ruff check .
Ruff has identified 9 errors and 1 fixable error. To fix the error, we will use the –fix flag.
ruff check --fix .
As you can see, it has fixed the 1 fixable error.
To format the project, we will use the `ruff format` command.
$ ruff format .
>>> 3 files reformatted
The Ruff linter and formatter have made numerous changes to the code. But, why do we require these tools? The answer is simple – they are beneficial in enforcing coding standards and conventions. As a result, both you and your team can concentrate on the significant aspects of your code. Moreover, they help enhance the quality, maintainability, and security of our code.
مصنف کے ذریعہ GIF
To use Ruff for Jupyter Notebooks in the project, you have to create `ruff.toml` file and add the following code:
extend-include = ["*.ipynb"]
You can also do the same with the `pyproject.toml` file.
After that re-run the commands to see it making changes to Jupyter notebook files.
2 files were reformatted and we have 2 Notebook files.
$ ruff format .
>>> 2 files reformatted, 3 files left unchanged
We have also fixed the issues in those files by running the `check` command again.
$ ruff check --fix .
>>> Found 51 errors (6 fixed, 45 remaining).
The final result is amazing. It has made all of the necessary changes without breaking the code.
مصنف کے ذریعہ GIF
It’s easy to configure Ruff for Jupyter Notebooks by editing the `ruff.toml` file to adjust the linter and formatter settings. Check out the configuring Ruff documentation مزید تفصیلات کے لئے.
target-version = "py311"
extend-include = ["*.ipynb"]
line-length = 80 [lint]
extend-select = [ "UP", # pyupgrade "D", # pydocstyle
] [lint.pydocstyle]
convention = "google"
Developers and teams can use Ruff as a pre-commit hook through the `ruff-pre-commit`:
- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.1.5 hooks: # Run the linter. - id: ruff args: [ --fix ] # Run the formatter. - id: ruff-format
It can also be used as a GitHub Action via `ruff-action`:
name: Ruff
on: [ push, pull_request ]
jobs: ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: chartboost/ruff-action@v1
The most enjoyable aspect of Ruff is its VSCode extension. It simplifies formatting and linting, eliminating the need for third-party extensions. Simply search for رف on the extension marketplace to install it.
سے تصویر Ruff – Visual Studio Marketplace
I have configured `setting.json` so that it formats on save.
Ruff delivers lightning-fast linting and formatting for cleaner, more consistent Python code. With over 700 built-in rules reimplemented in Rust for performance, Ruff draws inspiration from popular tools like Flake8, isort, and pyupgrade to enforce a comprehensive set of coding best practices. The curated ruleset focuses on catching bugs and critical style issues without excessive nitpicking.
Seamless integrations with pre-commit hooks, GitHub Actions, and editors like VSCode make incorporating Ruff into modern Python workflows easy. The unmatched speed and thoughtfully designed ruleset make Ruff an essential tool for Python developers who value rapid feedback, clean code, and smooth team collaboration. Ruff sets a new standard for Python linting and formatting by combining robust functionality with blazing performance.
عابد علی اعوان (@1abidaliawan) ایک سرٹیفائیڈ ڈیٹا سائنٹسٹ پروفیشنل ہے جو مشین لرننگ ماڈل بنانا پسند کرتا ہے۔ فی الحال، وہ مشین لرننگ اور ڈیٹا سائنس ٹیکنالوجیز پر مواد کی تخلیق اور تکنیکی بلاگ لکھنے پر توجہ دے رہا ہے۔ عابد کے پاس ٹیکنالوجی مینجمنٹ میں ماسٹر ڈگری اور ٹیلی کمیونیکیشن انجینئرنگ میں بیچلر ڈگری ہے۔ اس کا وژن دماغی بیماری کے ساتھ جدوجہد کرنے والے طلباء کے لیے گراف نیورل نیٹ ورک کا استعمال کرتے ہوئے ایک AI پروڈکٹ بنانا ہے۔
- SEO سے چلنے والا مواد اور PR کی تقسیم۔ آج ہی بڑھا دیں۔
- پلیٹو ڈیٹا ڈاٹ نیٹ ورک ورٹیکل جنریٹو اے آئی۔ اپنے آپ کو بااختیار بنائیں۔ یہاں تک رسائی حاصل کریں۔
- پلیٹوآئ اسٹریم۔ ویب 3 انٹیلی جنس۔ علم میں اضافہ۔ یہاں تک رسائی حاصل کریں۔
- پلیٹو ای ایس جی۔ کاربن، کلین ٹیک، توانائی ، ماحولیات، شمسی، ویسٹ مینجمنٹ یہاں تک رسائی حاصل کریں۔
- پلیٹو ہیلتھ۔ بائیوٹیک اینڈ کلینیکل ٹرائلز انٹیلی جنس۔ یہاں تک رسائی حاصل کریں۔
- ماخذ: https://www.kdnuggets.com/enhance-your-python-coding-style-with-ruff?utm_source=rss&utm_medium=rss&utm_campaign=enhance-your-python-coding-style-with-ruff
- : ہے
- : ہے
- $UP
- 1
- 10
- 12
- 51
- 7
- 700
- 8
- 80
- 9
- a
- عمل
- اعمال
- شامل کریں
- ایڈجسٹ
- پھر
- AI
- مقصد ہے
- تمام
- بھی
- حیرت انگیز
- an
- اور
- جواب
- کیا
- AS
- پہلو
- پہلوؤں
- خودکار
- BE
- فائدہ مند
- BEST
- بہترین طریقوں
- سیاہ
- بلیزنگ
- بلاگز
- دونوں
- توڑ
- کیڑوں
- تعمیر
- عمارت
- تعمیر میں
- لیکن
- by
- کر سکتے ہیں
- پکڑنے
- مصدقہ
- تبدیلیاں
- چیک کریں
- صاف
- کلینر
- کوڈ
- کوڈ بیس
- کوڈنگ
- تعاون
- امتزاج
- مطابقت
- وسیع
- توجہ
- تشکیل شدہ
- متواتر
- مواد
- مواد کی تخلیق
- کنونشن
- کنونشنوں
- تخلیق
- مخلوق
- اہم
- cured
- اس وقت
- اعداد و شمار
- ڈیٹا سائنس
- ڈیٹا سائنسدان
- ڈگری
- فراہم کرتا ہے
- ڈیزائن
- تفصیلات
- ڈویلپرز
- do
- مدد دیتی ہے
- آسانی سے
- آسان
- ایڈیٹر
- ایڈیٹرز
- ختم کرنا
- نافذ کریں
- نافذ کرنا
- انجنیئرنگ
- بڑھانے کے
- آننددایک
- خرابی
- نقائص
- ضروری
- موجودہ
- مدت ملازمت میں توسیع
- ملانے
- انتہائی
- فاسٹ
- تیز تر
- آراء
- فائل
- فائلوں
- فائنل
- درست کریں
- مقرر
- توجہ مرکوز
- توجہ مرکوز
- کے بعد
- کے لئے
- فارمیٹ
- فارمیٹ
- ملا
- سے
- فعالیت
- GIF
- GitHub کے
- گوگل
- گراف
- گراف نیورل نیٹ ورک
- ہے
- he
- مدد
- ان
- کی ڈگری حاصل کی
- ہکس
- کس طرح
- HTTPS
- ID
- کی نشاندہی
- بیماری
- کو بہتر بنانے کے
- in
- شامل کرنا
- پریرتا
- انسٹال
- انٹیگریٹٹس
- انضمام
- میں
- مسائل
- IT
- میں
- نوکریاں
- Jupyter نوٹ بک
- KDnuggets
- سیکھنے
- چھوڑ دیا
- بجلی کی تیز
- کی طرح
- لنکڈ
- محل وقوع
- سے محبت کرتا ہے
- مشین
- مشین لرننگ
- بنا
- برقرار رکھنے
- اہم
- بنا
- بنانا
- انتظام
- بازار
- ماسٹر
- ذہنی
- ذہنی بیماری
- ماڈل
- جدید
- زیادہ
- اس کے علاوہ
- سب سے زیادہ
- ضروری
- ضرورت ہے
- نیٹ ورک
- عصبی
- عصبی نیٹ ورک
- نئی
- نوٹ بک
- نوٹ بک
- متعدد
- of
- تجویز
- on
- اوپن سورس
- آپشنز کے بھی
- or
- احکامات
- ہمارے
- باہر
- پر
- خود
- pandas
- مساوات
- کارکردگی
- پلاٹا
- افلاطون ڈیٹا انٹیلی جنس
- پلیٹو ڈیٹا
- پلگ ان
- مقبول
- طریقوں
- مصنوعات
- پیشہ ورانہ
- منصوبے
- منصوبوں
- فراہم کرتا ہے
- پش
- ازگر
- معیار
- تیزی سے
- باقی
- کی جگہ
- ذخیرہ
- کی ضرورت
- نتیجہ
- مضبوط
- قوانین
- رن
- چل رہا ہے
- مورچا
- s
- اسی
- محفوظ کریں
- سائنس
- سائنسدان
- تلاش کریں
- سیکورٹی
- دیکھنا
- مقرر
- سیٹ
- ترتیبات
- اہم
- سادہ
- صرف
- ایک
- ہموار
- So
- تیزی
- معیار
- معیار
- مراحل
- جدوجہد
- طلباء
- سٹوڈیو
- سٹائل
- حمایت
- کی حمایت کرتا ہے
- ٹیم
- ٹیموں
- ٹیکنیکل
- ٹیکنالوجی
- ٹیکنالوجی
- ٹیلی مواصلات
- ٹیسٹ
- سے
- کہ
- ۔
- یہ
- وہ
- تیسری پارٹی
- اس
- ان
- کے ذریعے
- کرنے کے لئے
- کے آلے
- اوزار
- متحد
- بے مثال
- صلی اللہ علیہ وسلم
- استعمالی
- استعمال کی شرائط
- استعمال کیا جاتا ہے
- استعمال
- کا استعمال کرتے ہوئے
- قیمت
- ورژن
- کی طرف سے
- نقطہ نظر
- بصری
- we
- تھے
- جبکہ
- ڈبلیو
- کیوں
- گے
- ساتھ
- بغیر
- کام کے بہاؤ
- تحریری طور پر
- لکھا
- آپ
- اور
- زیفیرنیٹ