Skip to content

Add ruff formatter and linter#183

Open
rads-1996 wants to merge 15 commits into
microsoft:mainfrom
rads-1996:add-ruff
Open

Add ruff formatter and linter#183
rads-1996 wants to merge 15 commits into
microsoft:mainfrom
rads-1996:add-ruff

Conversation

@rads-1996

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR switches the repo’s formatting/lint workflow from Black to Ruff, adds Ruff configuration to pyproject.toml, and applies formatting/type-hint modernization across the codebase (built-in generics, collections.abc imports, and minor style cleanups).

Changes:

  • Replace the black tox environment with a ruff tox environment and add Ruff to dev dependencies.
  • Add [tool.ruff] configuration (lint + formatter settings) in pyproject.toml.
  • Apply repo-wide formatting and typing updates (e.g., Dictdict, Listlist, typing.Sequencecollections.abc.Sequence), plus minor test/sample formatting.

Reviewed changes

Copilot reviewed 48 out of 50 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tox.ini Replaces Black env with Ruff env for lint/format checks.
pyproject.toml Drops Black config; adds Ruff config and dev dependency.
dev_requirements.txt Swaps Black for Ruff in dev requirements.
tests/test_sdkstats.py Formatting-only tuple spacing changes.
tests/test_openai_agents_integration.py Reformats nested with patch(...) into parenthesized context manager form.
tests/test_langchain_integration.py Removes unused import line (format/lint cleanup).
tests/test_distro.py Reformats nested with patch(...) into parenthesized context manager form.
tests/openai_agents/test_trace_instrumentor.py Reformats nested with patch(...) into parenthesized context manager form.
tests/langchain/test_utils.py Minor style cleanup (kwargs.get(..., None)kwargs.get(...)) and whitespace.
tests/langchain/test_tracer.py Minor style cleanup and list/dict literal formatting.
tests/langchain/test_main_agent_propagation.py Minor style cleanup (kwargs.get(..., None)kwargs.get(...)).
tests/azure_monitor/diagnostics/test_status_logger.py Simplifies open() calls (drops redundant "r").
tests/azure_monitor/diagnostics/test_diagnostic_logging.py Simplifies open() calls (drops redundant "r").
tests/azure_monitor/browserSdkLoader/test_django_middleware.py Removes blank lines for formatter compliance.
tests/a365/test_exporter.py Reflows long assertion dict literal for formatter compliance.
tests/a365/runtime/test_utility.py Collapses nested context managers and reindents blocks.
tests/a365/runtime/test_export_config_consistency.py Fixes f-string concatenation formatting.
tests/a365/integration/openai/test_openai_trace_processor.py Reflows long calls/comprehensions and simplifies condition formatting.
tests/a365/integration/openai/test_message_format.py Reflows list/dict building and assertion formatting.
tests/a365/integration/langchain/test_observability_pipeline.py Reflows assertions/comprehensions for formatter compliance.
tests/a365/integration/langchain/test_message_format.py Reflows assertions/comprehensions for formatter compliance.
tests/a365/integration/agentframework/test_observability_pipeline.py Reflows assertions for formatter compliance.
tests/a365/integration/agentframework/test_message_format.py Reflows async test signatures and assertions for formatter compliance.
tests/a365/integration/agentframework/test_agentframework_trace_processor.py Reflows function signature and conditions for formatter compliance.
src/microsoft/opentelemetry/a365/runtime/operation_result.py Updates typing to built-in generics (list[...]) and trims unused typing imports.
src/microsoft/opentelemetry/a365/core/message_utils.py Reflows list comprehension formatting.
src/microsoft/opentelemetry/a365/core/inference_scope.py Updates List[str]list[str] typing.
src/microsoft/opentelemetry/a365/core/exporters/utils.py Updates List[...]list[...] typing and trims unused typing imports.
src/microsoft/opentelemetry/a365/core/exporters/span_processor.py Simplifies invoke-agent detection condition formatting.
src/microsoft/opentelemetry/a365/core/exporters/enriched_span.py Updates Set[str]set[str] typing and trims unused typing imports.
src/microsoft/opentelemetry/_utils.py Updates Dict[...]dict[...] typing and trims unused typing imports.
src/microsoft/opentelemetry/_types.py Uses collections.abc.Sequence instead of typing.Sequence.
src/microsoft/opentelemetry/_sdkstats/_utils.py Updates Dict/Tuple typing to built-in generics and trims unused typing imports.
src/microsoft/opentelemetry/_sdkstats/_metrics.py Uses collections.abc.Iterable and built-in generics typing.
src/microsoft/opentelemetry/_sdkstats/_constants.py Removes stray blank line.
src/microsoft/opentelemetry/_instrumentation.py Uses collections.abc.Collection instead of typing.Collection.
src/microsoft/opentelemetry/_genai/_openai_agents/_message_mapper.py Simplifies conditional branches for message mapping.
src/microsoft/opentelemetry/_genai/_langchain/_utils.py Removes stray blank line.
src/microsoft/opentelemetry/_distro.py Updates multiple Dict/List annotations to built-in generics and trims unused typing imports.
src/microsoft/opentelemetry/_azure_monitor/_utils/instrumentation.py Uses collections.abc.Collection instead of typing.Collection.
src/microsoft/opentelemetry/_azure_monitor/_utils/configurations.py Updates Dict[...] to dict[...] and adjusts cast usage accordingly.
src/microsoft/opentelemetry/_azure_monitor/_types.py Uses collections.abc.Sequence instead of typing.Sequence.
src/microsoft/opentelemetry/_azure_monitor/_diagnostics/diagnostic_logging.py Simplifies super().__new__ call in singleton __new__.
src/microsoft/opentelemetry/_azure_monitor/_configure.py Updates Dict/List typing to built-in generics and related casts.
src/microsoft/opentelemetry/_azure_monitor/_browser_sdk_loader/snippet_injector.py Updates typing (Tupletuple, Dictdict) and trims unused imports.
src/microsoft/opentelemetry/_azure_monitor/_browser_sdk_loader/django_middleware.py Uses collections.abc.Callable instead of typing.Callable.
src/microsoft/opentelemetry/_azure_monitor/_browser_sdk_loader/_config.py Updates Dict[...] to dict[...] typing.
samples/microsoft_agent_framework/sample_maf_agent.py Fixes indentation for formatter compliance.
samples/langchain/validate_traces.py Reflows f-strings and list comprehensions for formatter compliance.
samples/a365/manual_telemetry.py Removes stray blank lines for formatter compliance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/microsoft/opentelemetry/a365/runtime/operation_result.py
Comment thread pyproject.toml
Comment thread tox.ini

@JacksonWeber JacksonWeber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@rads-1996

Copy link
Copy Markdown
Member Author

Will keep on hold before merging. Need to get everyone's opinion of this tool vs black and pylint

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants