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

Make ruff sort imports #47

Merged
merged 1 commit into from
May 22, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
args: [ --select, I, --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
Comment on lines 16 to 22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODE REVIEW

Your changes improve the specific linting rules applied. However:

  1. Validate that ruff-format aligns with your code style.
  2. Ensure the removed repo: for mypy is intentional.

Example:

hooks:
  - id: ruff
    args: [ --select I, --fix ]
  - id: ruff-format  
  - repo: https://github.com/pre-commit/mirrors-mypy
    id: mypy

Expand Down
9 changes: 4 additions & 5 deletions src/tyora/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import argparse
import json
import logging
from dataclasses import dataclass, field
from enum import Enum
from getpass import getpass
import logging
import json
from urllib.parse import urljoin
from pathlib import Path
from time import sleep
from typing import AnyStr, Optional
from urllib.parse import urljoin
from xml.etree.ElementTree import Element, tostring

from html2text import html2text
import htmlement
import requests

from html2text import html2text

logger = logging.getLogger(name="tyora")

Comment on lines 1 to 18

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODE REVIEW

Your import reorganization improves readability, but some imports still need adjustments.

  1. Standard Imports First: Arrange built-in modules before third-party ones.
  2. Alphabetical Order: Sort imports alphabetically within each group.
import argparse
import json
import logging
from dataclasses import dataclass, field
from enum import Enum
from getpass import getpass
from pathlib import Path
from time import sleep
from typing import AnyStr, Optional
from urllib.parse import urljoin
from xml.etree.ElementTree import Element, tostring

import html2text
import htmlement
import requests

Expand Down
2 changes: 1 addition & 1 deletion stubs/htmlement.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from html.parser import HTMLParser
import io
from html.parser import HTMLParser
from typing import Optional
from xml.etree.ElementTree import Element

Comment on lines 1 to 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODE REVIEW

Great addition of Optional from the typing module. Minor formatting improvement: maintain alphabetical order.

from html.parser import HTMLParser
from typing import Optional
from xml.etree.ElementTree import Element
import io

Expand Down
2 changes: 1 addition & 1 deletion tests/test_tyora.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import tyora
import pytest
import requests_mock
import tyora


def test_parse_args_missing_args() -> None:
Comment on lines 1 to 6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CODE REVIEW

  • No need to re-import tyora after requests_mock.
  • Ensure imports are sorted alphabetically.
import pytest
import requests_mock
import tyora

This keeps imports clean and manageable.

Expand Down