Skip to content

chore: apply fixes for UP ruff rule#5133

Open
emdneto wants to merge 18 commits intoopen-telemetry:mainfrom
emdneto:up-ruff-rule
Open

chore: apply fixes for UP ruff rule#5133
emdneto wants to merge 18 commits intoopen-telemetry:mainfrom
emdneto:up-ruff-rule

Conversation

@emdneto
Copy link
Copy Markdown
Member

@emdneto emdneto commented Apr 21, 2026

Description


opentelemetry._logs._internal.LogRecord:1:more than one target located for cross-referencing 'Context': opentelemetry.context.Context, opentelemetry.context.context.Context

99% of the changes were made by ruff with ruff check --fix. The agent removed the unused imports and fixed minor issues.

Fixes #4227

This is important to make our codebase updated with the most recent supported syntax.

Assisted-by: Copilot

@emdneto emdneto requested a review from a team as a code owner April 21, 2026 22:42
@DylanRussell
Copy link
Copy Markdown
Contributor

nice. couple failed CI checks but otherwise LGTM

@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Apr 22, 2026
@emdneto emdneto moved this from Approved PRs to Ready for review in Python PR digest Apr 22, 2026
Copy link
Copy Markdown
Member Author

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

Note for manual changes i've done in 6051e44 and 874317d to make CI pass

@emdneto emdneto added the Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary label Apr 22, 2026
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Looks good. Some linter checks failed that will need to be cleaned up.

Comment thread CHANGELOG.md Outdated
@MikeGoldsmith MikeGoldsmith moved this from Ready for review to Approved PRs in Python PR digest Apr 27, 2026
@DylanRussell
Copy link
Copy Markdown
Contributor

If you have time I think we could do the same thing in the contrib repo: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/pyproject.toml#L162

@emdneto
Copy link
Copy Markdown
Member Author

emdneto commented Apr 27, 2026

If you have time I think we could do the same thing in the contrib repo: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/pyproject.toml#L162

That's the plan after getting this merged

@emdneto emdneto changed the title Apply fixes for UP ruff rule chore: apply fixes for UP ruff rule May 6, 2026
@xrmx xrmx moved this from Approved PRs to Ready for merge in Python PR digest May 7, 2026
@emdneto
Copy link
Copy Markdown
Member Author

emdneto commented May 7, 2026

Answering the question from today's SIG: is it safe for downstream typecheckers? E.g. Typing -> collections.abc

I wrote this PoC:

//lib_sdk.py

from collections.abc import Callable


def parse_value(v: str | int) -> str: return str(v)
def run_callback(cb: Callable[[str], int]) -> int: return cb("hi")

//downstream.py

from typing import Callable, Union

from lib_sdk import parse_value, run_callback

value: Union[str, int] = parse_value("abc")

def cb(s: str) -> int: return len(s)
old_cb: Callable[[str], int] = cb
run_callback(old_cb)

And later:

pyright --pythonversion 3.10 downstream.py
0 errors, 0 warnings, 0 informations

cc @xrmx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary

Projects

Status: Ready for merge

Development

Successfully merging this pull request may close these issues.

Add more rules to ruff linter

4 participants