Skip to content

Fix linting issues: Add docstrings and type annotations to oidc_pkce.py#740

Draft
Copilot wants to merge 4 commits intojnovak/saas_testingfrom
copilot/fix-unused-variables-and-docs
Draft

Fix linting issues: Add docstrings and type annotations to oidc_pkce.py#740
Copilot wants to merge 4 commits intojnovak/saas_testingfrom
copilot/fix-unused-variables-and-docs

Conversation

Copy link

Copilot AI commented Jan 28, 2026

Description

Fixed 14 linting violations in oidc_pkce.py by adding missing docstrings and type annotations. The F841 errors (unused variables in examples/mapdl_motorbike_frame/project_setup.py) mentioned in the issue do not exist in the current codebase.

Changes Made

  • Documentation: Added docstrings to all public classes (OAuthHttpServer, OAuthHttpHandler), methods (__init__, do_GET, log_message), and functions (generate_code, prepare_auth_url, find_free_port, login, get_config)
  • Type Annotations: Added complete type hints to function signatures, including fixing incorrect return type on login (was -> str, now -> tuple[str, str, str])
  • Formatting: Fixed module docstring format (D205, D212) and line length (E501)

All changes are documentation-only with no functional modifications.

Checklist

  • I have tested these changes locally.
  • I have added unit tests (if appropriate).
  • I have added necessary documentation or updated existing documentation.
  • I have linked the issue(s) addressed by this PR if any.
Original prompt

Fix these issues in my code:
examples\mapdl_motorbike_frame\project_setup.py:179:5: F841 Local variable param_mappings is assigned to but never used
|
178 | # Parameter mappings
179 | param_mappings = []
| ^^^^^^^^^^^^^^ F841
180 | pi = 0
181 | """
|
= help: Remove assignment to unused variable param_mappings

examples\mapdl_motorbike_frame\project_setup.py:180:5: F841 Local variable pi is assigned to but never used
|
178 | # Parameter mappings
179 | param_mappings = []
180 | pi = 0
| ^^ F841
181 | """
182 | for i in range(1, 4):
|
= help: Remove assignment to unused variable pi

oidc_pkce.py:1:1: D205 1 blank line required between summary line and description
|
1 | / """Script to demonstrate how to authenticate with an OIDC provider
2 | | using the Authorization Code Flow with PKCE.
3 | |
4 | | Mostly inspired by:
5 | | - https://www.camiloterevinto.com/post/oauth-pkce-flow-from-python-desktop
6 | | - https://www.stefaanlippens.net/oauth-code-flow-pkce.html
7 | | """
| |___^ D205
8 |
9 | import argparse
|
= help: Insert single blank line

oidc_pkce.py:24:7: D101 Missing docstring in public class
|
24 | class OAuthHttpServer(HTTPServer):
| ^^^^^^^^^^^^^^^ D101
25 | def init(self, *args, **kwargs):
26 | HTTPServer.init(self, *args, **kwargs)
|

oidc_pkce.py:25:9: D107 Missing docstring in __init__
|
24 | class OAuthHttpServer(HTTPServer):
25 | def init(self, *args, **kwargs):
| ^^^^^^^^ D107
26 | HTTPServer.init(self, *args, **kwargs)
27 | self.authorization_code = ""
|

oidc_pkce.py:30:7: D101 Missing docstring in public class
|
30 | class OAuthHttpHandler(BaseHTTPRequestHandler):
| ^^^^^^^^^^^^^^^^ D101
31 | def do_GET(self):
32 | parsed = parse.urlparse(self.path)
|

oidc_pkce.py:31:9: N802 Function name do_GET should be lowercase
|
30 | class OAuthHttpHandler(BaseHTTPRequestHandler):
31 | def do_GET(self):
| ^^^^^^ N802
32 | parsed = parse.urlparse(self.path)
33 | qs = parse.parse_qs(parsed.query)
|

oidc_pkce.py:31:9: D102 Missing docstring in public method
|
30 | class OAuthHttpHandler(BaseHTTPRequestHandler):
31 | def do_GET(self):
| ^^^^^^ D102
32 | parsed = parse.urlparse(self.path)
33 | qs = parse.parse_qs(parsed.query)
|

oidc_pkce.py:53:9: D102 Missing docstring in public method
|
51 | self.wfile.write(html_body)
52 |
53 | def log_message(self, format, *args):
| ^^^^^^^^^^^ D102
54 | return
|

oidc_pkce.py:57:5: D103 Missing docstring in public function
|
57 | def generate_code() -> tuple[str, str]:
| ^^^^^^^^^^^^^ D103
58 | code_verifier = base64.urlsafe_b64encode(os.urandom(40)).decode("utf-8")
59 | code_verifier = re.sub("[^a-zA-Z0-9]+", "", code_verifier)
|

oidc_pkce.py:68:5: D103 Missing docstring in public function
|
68 | def prepare_auth_url(
| ^^^^^^^^^^^^^^^^ D103
69 | auth_url, redirect_uri, code_challenge, client_id="rep-cli", scope="openid"
70 | ) -> str:
|

oidc_pkce.py:90:5: D103 Missing docstring in public function
|
90 | def find_free_port():
| ^^^^^^^^^^^^^^ D103
91 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
92 | s.bind(("", 0))
|

oidc_pkce.py:99:5: D103 Missing docstring in public function
|
99 | def login(config: dict[str, Any], verify) -> str:
| ^^^^^ D103
100 | port = find_free_port()
101 | with OAuthHttpServer(("", port), OAuthHttpHandler) as httpd:
|

oidc_pkce.py:145:5: D103 Missing docstring in public function
|
145 | def get_config(hps_url, verify):
| ^^^^^^^^^^ D103
146 | jms_url = hps_url.rstrip("/") + "/jms/api/v1"
147 | response = requests.get(url=jms_url, verify=verify)
|

Found 20 errors (6 fixed, 14 remaining).
No fixes available (2 hidden fixes can be enabled with the --unsafe-fixes option).

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

pre-commit-ci bot and others added 3 commits January 28, 2026 08:56
Co-authored-by: Buzz1167 <89214851+Buzz1167@users.noreply.github.com>
Co-authored-by: Buzz1167 <89214851+Buzz1167@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unused variable assignments and docstring formatting Fix linting issues: Add docstrings and type annotations to oidc_pkce.py Jan 28, 2026
Copilot AI requested a review from Buzz1167 January 28, 2026 09:04
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