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

Don't re-export imports outside of __init__.py #2226

Merged
merged 3 commits into from
May 28, 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 .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- run: pycln . --config=pycln.toml --check
- uses: chartboost/ruff-action@v1
with:
version: '0.3.4'
version: '0.3.7'
- uses: psf/black@stable
with:
options: "--fast --check --diff --verbose"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ repos:
args: [--config=pycln.toml]
verbose: true
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
rev: v0.3.7
hooks:
- id: ruff # Run the linter.
args: [--fix]
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/framework/scriptutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def CheckFile():


def RunTabNanny(filename):
import io as io
import io

tabnanny = FindTabNanny()
if tabnanny is None:
Expand Down
2 changes: 1 addition & 1 deletion adodbapi/process_connect_string.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" a clumsy attempt at a macro language to let the programmer execute code on the server (ex: determine 64bit)"""

from . import is64bit as is64bit
from . import is64bit
vernondcole marked this conversation as resolved.
Show resolved Hide resolved


def macro_call(macro_name, args, kwargs):
Expand Down
4 changes: 2 additions & 2 deletions com/win32com/client/gencache.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
# Typing as Any because PyITypeLib is not exposed
demandGeneratedTypeLibraries: dict[tuple[str, int, int, int], Any] = {}

import pickle as pickle
import pickle


def __init__():
Expand Down Expand Up @@ -91,7 +91,7 @@ def _SaveDicts():
def _LoadDicts():
# Load the dictionary from a .zip file if that is where we live.
if is_zip:
import io as io
import io

loader = win32com.__loader__
arc_path = loader.archive
Expand Down
20 changes: 14 additions & 6 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# Target the oldest supported version
target-version = "py37"

[lint]
select = ["I"]
select = [
"I", # isort
"PLC", # Pylint Convention
]

[lint.per-file-ignores]
# Explicit re-exports is fine in __init__.py, still a code smell elsewhere.
"__init__.py" = ["PLC0414"]
Copy link
Collaborator Author

@Avasam Avasam Mar 25, 2024

Choose a reason for hiding this comment

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


[lint.isort]
combine-as-imports = true
# Because pywin32 has a mix of relative and absolute imports, with undetectable first-party c-extensions
# This makes import grouping more consistent
detect-same-package = false
known-third-party = [
"__main__",
# This forces distutils imports to always be after setuptools
# setuptools must be imported before distutils because it monkey-patches it.
# distutils is also removed in Python 3.12 and deprecated with setuptools
"distutils",
"__main__",
# This forces distutils imports to always be after setuptools
# setuptools must be imported before distutils because it monkey-patches it.
# distutils is also removed in Python 3.12 and deprecated with setuptools
"distutils",
]
extra-standard-library = ["setuptools"]
4 changes: 3 additions & 1 deletion win32/winxpgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import warnings

from win32console import GetConsoleWindow as GetConsoleWindow
from win32console import (
GetConsoleWindow as GetConsoleWindow, # noqa: PLC0414 # Explicit re-export
)
from win32gui import *

warnings.warn(
Expand Down
Loading