Skip to content

Comments

Update Python guidelines: remove Python 2, modernize typing for 3.9+, promote keyword-only args over **kwargs#2

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/remove-python2-guidance
Draft

Update Python guidelines: remove Python 2, modernize typing for 3.9+, promote keyword-only args over **kwargs#2
Copilot wants to merge 4 commits intomasterfrom
copilot/remove-python2-guidance

Conversation

Copy link

Copilot AI commented Feb 12, 2026

Two sets of guideline changes: (1) remove all Python 2 compatibility guidance and update typing for a 3.9+ minimum, and (2) restrict **kwargs usage to pass-through scenarios only.

Python 2 removal & typing modernization (design.md, implementation.md)

  • Minimum version: 3.8 → 3.9
  • Removed azure-nspkg / azure-<group>-nspkg dependency requirements
  • Removed collections fallback (Python 2.7), "straddling code" PEP 484 reference, (object) base class from examples, "only need to support Python 3" qualifiers, Python 3.4/3.5 historical references
  • Added PEP 585 requirement — use list[str] not typing.List[str]
  • Added Union/Optional guidance with comment noting PEP 604 X | Y syntax for when minimum moves to 3.10+
# 3.9+
def get_things() -> list[str]: ...
def foo(x: Union[int, str]) -> Optional[str]: ...

# When minimum is 3.10+:
# def foo(x: int | str) -> str | None: ...

Keyword-only arguments over **kwargs (implementation.md, design.md, documentation.md)

  • Added MUSTNOT (python-codestyle-no-kwargs-for-arguments): **kwargs must not be used for arguments consumed by the method — use keyword-only args
  • Added MAY (python-codestyle-kwargs-passthrough): **kwargs allowed only for pass-through, must document target API(s)
  • Updated docstring requirements in both design.md and documentation.md to require documenting which API(s) receive forwarded **kwargs
  • Removed **kwargs as alternative in python-codestyle-long-args
# Yes — explicit keyword-only arguments:
def create_thing(name: str, *, size: int = 0, color: str = "blue") -> None: ...

# No — kwargs.pop pattern for consumed arguments:
def create_thing(name: str, **kwargs) -> None:
    size = kwargs.pop("size", 0)
    ...

# OK — pass-through with documented target:
def get_thing(self, name: str, **kwargs) -> "Thing":
    """Keyword arguments are passed to the HTTP pipeline.
    See https://aka.ms/azsdk/python/options.
    """
    return self._pipeline.send(request, **kwargs)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove Python2 guidance and update Python3 typing guidelines Remove Python 2 guidance and update typing guidelines for Python 3.9+ minimum Feb 12, 2026
Copilot AI requested a review from johanste February 12, 2026 22:50
…forwarded kwargs targets

Co-authored-by: johanste <15110018+johanste@users.noreply.github.com>
Copilot AI changed the title Remove Python 2 guidance and update typing guidelines for Python 3.9+ minimum Update Python guidelines: remove Python 2, modernize typing for 3.9+, promote keyword-only args over **kwargs Feb 12, 2026
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.

2 participants