Skip to content

Refactor _from server socket#820

Open
julianz- wants to merge 11 commits intocherrypy:mainfrom
julianz-:refactor__from_server_socket
Open

Refactor _from server socket#820
julianz- wants to merge 11 commits intocherrypy:mainfrom
julianz-:refactor__from_server_socket

Conversation

@julianz-
Copy link
Copy Markdown
Member

@julianz- julianz- commented Apr 7, 2026

This function in connections.py had become highly nested and complex, triggering linter warnings (C901, WPS505). Decomposed the logic into several smaller private methods.

What kind of change does this PR introduce?

  • 🐞 bug fix
  • 🐣 feature
  • 📋 docs update
  • 📋 tests/coverage improvement
  • 📋 refactoring
  • 💥 other

📋 What is the related issue number (starting with #)

Resolves #

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?
None

📋 Other information:
📋 Contribution checklist:

(If you're a first-timer, check out
[this guide on making great pull requests][making a lovely PR])

  • I wrote descriptive pull request text above
  • I think the code is well written
  • I wrote [good commit messages]
  • I have [squashed related commits together][related squash] after
    the changes have been approved
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Documentation reflects the changes
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences

Will squash on approval

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Apr 7, 2026

Documentation build overview

📚 cheroot | 🛠️ Build #32192177 | 📁 Comparing c9842c0 against latest (2ffb0ba)

  🔍 Preview build  

Show files changed (8 files in total): 📝 8 modified | ➕ 0 added | ➖ 0 deleted
File Status
genindex/index.html 📝 modified
history/index.html 📝 modified
pkg/cheroot/index.html 📝 modified
pkg/cheroot.connections/index.html 📝 modified
pkg/cheroot.server/index.html 📝 modified
pkg/cheroot.ssl.pyopenssl/index.html 📝 modified
pkg/cheroot.test/index.html 📝 modified
pkg/cheroot.test.test_ssl/index.html 📝 modified

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 95.86777% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.78%. Comparing base (2ffb0ba) to head (c9842c0).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #820      +/-   ##
==========================================
+ Coverage   78.32%   78.78%   +0.46%     
==========================================
  Files          41       41              
  Lines        4788     4869      +81     
  Branches      547      554       +7     
==========================================
+ Hits         3750     3836      +86     
+ Misses        900      893       -7     
- Partials      138      140       +2     

@julianz- julianz- force-pushed the refactor__from_server_socket branch 4 times, most recently from 1f86831 to b2f990a Compare April 8, 2026 04:38
julianz- added 10 commits April 9, 2026 11:57
This is the first in a sequence of refactors for
this function. This step moves the initialization
of the remote address to a separate helper function
Moves the check on ignorable errors into
a separate function.
Puts the wrapping call into its own function.
the try hamdler had multiple statements
The accept() call is now handled in _accept_conn()
Helper function for security marks the socket
fd as non-inheritable and sets the timeout.
Using helper functions this function now
just has two main steps. First, socket creation.
Second, connection configuration.
Added to deal with comment in _setup_conn_addr()
These tests cover code that was previous not covered.
@julianz- julianz- force-pushed the refactor__from_server_socket branch from b2f990a to de7bee4 Compare April 9, 2026 19:23
Update expected SSL error substrings to match the format returned by
Python 3.15 on Windows Server 2025 runners. This unblocks CI coverage
reports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants