aiosmtpd
aiosmtpd copied to clipboard
Tidying __init__
~~Depends on #256 , #259 , and #260 ; please merge them first.~~ All deps have been merged. We can go ahead with this one.
What do these changes do?
The __init__ method is very unwieldy. This PR makes it simpler by extracting some logic into properties.
This led to several improvements:
event_handlercan be replaced "on-the-fly"tls_contextcan be replaced "on-the-fly" and will automagically changerequire_tlsaccordingly- User can selectively overload logic in the properties; no longer have to copy > 100 lines of init code just to override one behavior 😉
Are there changes in behavior for the user?
None.
Users have to be aware though that some properties are more 'noisy' in logging.
Related issue number
Inspired partially by #253
Checklist
- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] tox testenvs have been executed in the following environments:
- [x] Windows 10 (via PyCharm tox runner)
- [x] Windows 10 (via PSCore 7.1.2)
- [x] Windows 10 (via Cygwin)
- [x] Ubuntu 18.04 on WSL 1.0
- [x] FreeBSD 12.2 on VBox
- [x] OpenSUSE Leap 15.2 on VBox
- [x] Documentation reflects the changes
- [x] Add a news fragment into the
NEWS.rstfile
Codecov Report
Merging #261 (4bd08bb) into master (4bd08bb) will not change coverage. The diff coverage is
n/a.
:exclamation: Current head 4bd08bb differs from pull request most recent head 5f3557c. Consider uploading reports for the commit 5f3557c to get more accurate results
@@ Coverage Diff @@
## master #261 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 1706 1706
Branches 310 310
=========================================
Hits 1706 1706
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Now that I think of it ... this should be merged ONLY after #260 has been merged.
That way, I can test for the behavior of the library when tls_context is being replaced totally. (Current tests are replacing to/from None, and replacing with a new SSLContext object but using the same cert-key pair.)
Nice. I'm digging at least the idea :)
As soon as test passes on my testing systems, I'm undrafting this and let this marinate.
I might not be able to do code changes for several days ahead, due to me transitioning from "being employed" to "being a free agent" and needing to acquire a new laptop. I reckon up to a week of radio silence due to the Easter holidays. Hopefully not as long as that, depending on how soon the store can fulfill my order.
Nice. I'm digging at least the idea :)
A side effect is that SMTP instatiation is now faster 😉
@pepoluan I'm going to plan on taking a closer look at this one this week, too. Looks like there are a couple of conflicts, if you're able to tackle those.
@pepoluan I'm going to plan on taking a closer look at this one this week, too. Looks like there are a couple of conflicts, if you're able to tackle those.
Fixed the conflicts, rebase, and let's see...
Oh gosh it blew up! LOL
Heh seriously at this point I'll just close this PR, but grab the ideas and make a new PR based on the latest master.
There are just too many incremental changes since this PR was created, the proposed changes in this PR makes things go awry.