-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port twisted.names.authority.BindAuthority to Py3 #579
Conversation
Current coverage is 90.74% (diff: 94.89%)@@ trunk #579 diff @@
==========================================
Files 815 815
Lines 145980 146021 +41
Methods 0 0
Messages 0 0
Branches 12875 12882 +7
==========================================
+ Hits 132389 132505 +116
+ Misses 11322 11245 -77
- Partials 2269 2271 +2
|
There are a couple of twistedchecker failures - can you fix those? Thanks! |
Underway I had to fix a few bugs/annoyances. Most notably: - Fix a major bug in addRecord that didn't remove the final dot if an owner/origin is added. - Remove a (debug!?) print statement when adding records. - Reflect explicit $ORIGIN in instance. - Add discouraging docstrings to public helper methods that should be private. These should be deprecated ASAP. - Remove a bunch of commented out debug print statements.
Look at all those green build jobs! |
Thanks for the patch. The release notes only talks about porting to python3. Since in this branch you have also fixed a few bugs, shouldn't we advertise this in the release notes? |
def getSerial(filename = '/tmp/twisted-names.serial'): | ||
"""Return a monotonically increasing (across program runs) integer. | ||
|
||
def getSerial(filename='/tmp/twisted-names.serial'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is targeting python3, is filename a native string, bytes or unicode?
with the move to python3 I think that it would help to be explicit if something is text or data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISTM that for paths a filename is OK to be a native string. Are there any precedences?
I’d also like to point out, that I just touched this function to make twistedchecker shut up. Starting to fix it up seems out of scope? NB I’m not asking because I’m lazy, I’m asking because I’m not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing it is definitely out of scope. And we should probably figure out how to make twistedchecker not complain about stuff that is merely adjacent to your diff rather than part of it...
# self._cache[(name, cls, type)] = r | ||
# return r | ||
serial = serial + ('%02d' % (ID,)) | ||
serialFile.write('%s %d' % (serial, id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use FIlePath here? I think that it should take care of handling the path encoding issues.
@@ -161,25 +156,32 @@ def _lookup(self, name, cls, type, timeout = None): | |||
else: | |||
ttl = default_ttl | |||
|
|||
if record.TYPE == dns.NS and name.lower() != self.soa[0].lower(): | |||
if record.TYPE == dns.NS and \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you should use parenthesis to break long lines .... but twistechecker should have complain about this
I thought about the release notes thing but wasn’t sure how to phrase it (especially because the bugs are rather subtle). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, @hynek . This is generally a great branch and I like most of the cleanups. However, if you could address the few nitpicks it would be great.
If you can push these changes to a branch on Twisted itself, then the all the buildbots should run and I think the coverage issues will be addressed. If not, please pacify codecov by adding tests for any uncovered lines.
@@ -34,28 +44,14 @@ def getSerial(filename = '/tmp/twisted-names.serial'): | |||
os.umask(o) | |||
|
|||
with open(filename, 'r') as serialFile: | |||
lastSerial, ID = serialFile.readline().split() | |||
lastSerial, id = serialFile.readline().split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
is a builtin, which is why this was previously capitalized :).
Perhaps zoneID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
twistedchecker complained about ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically (naming-standard-wise) it is correct to complain; it should just also be complaining about id
. zoneID
ought to be OK with it though.
serial = serial + ('%02d' % (ID,)) | ||
serialFile.write('%s %d' % (serial, id)) | ||
|
||
serial = serial + ('%02d' % (id,)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: .format
instead of %
because it's ~fancier~?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it’s slower? :)
@type filename: L{bytes} | ||
""" | ||
fp = FilePath(filename) | ||
# XXX - not the best way to set an origin. It can be set using $ORIGIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per policy, XXX and FIXME comments should be links to tickets.
return [ | ||
a.find(';') == -1 and a or a[:a.find(';')] for a in [ | ||
""" | ||
This is a private API; do not use in application code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this method private and then add a deprecated public alias? Deprecation should be communicated structurally in a way that automated tooling can deal with, not with ad-hoc doc comments.
|
||
|
||
def collapseContinuations(self, lines): | ||
L = [] | ||
""" | ||
This is a private API; do not use in application code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above comment.
TTL = 60 * 60 * 3 | ||
ORIGIN = self.origin | ||
""" | ||
This is a private API; do not use in application code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above about private APIs.
if not domain.endswith('.'): | ||
domain = domain + '.' + owner | ||
""" | ||
This is a private API; do not use in application code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK hang on a second. Are these APIs really private? It feels like maybe somebody is using them. Maybe we can just delete the deprecations in this branch and do that separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How am I supposed to document them to make twistedchecker shut up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like an unrelated question, but... txchecker-travis is passing :).
You already have a docstring here, so if you just delete the line This is a private API; do not use in application code.
it should still be fine with it.
Am I misunderstanding the question?
|
||
def test_aaaaRecords(self): | ||
""" | ||
AAAA records are loaded correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per https://jml.io/pages/test-docstrings.html, "correctly" is a non-word :).
|
||
def test_mxRecords(self): | ||
""" | ||
MX records are loaded correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
def test_invalidRecordClass(self): | ||
""" | ||
Raises NotImplementedError on invalid records. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence should have a subject.
@param rdata: record data | ||
@type rdata: L{list} of L{bytes} | ||
|
||
@return: nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: there's no return
statement in the body of the function, so twistedchecker and pydoctor ought not to complain if you just omit @return
entirely. And anywhere twistedchecker lets us omit stuff we probably should :). (If I'm wrong about this please correct me).
Coverage is failing. At least one case is directly relevant to your changes: https://codecov.io/gh/twisted/twisted/compare/f520d35bfd552f0da91b248171d25789170110ae...1dd9c449504b07652af650382fc46b566fcd8546#7372632F747769737465642F6E616D65732F617574686F726974792E7079-86 Others are not new but triggering due to reformatting of code: Since recently policy says no overriding of these is allowed, you probably need to un-reformat that code or test it. |
Actually I mis-read the "directly relevant" example; you removed an adjacent line, so again, cleanup is causing coverage to complain. |
It looks like @hynek did in fact address all the review feedback, and the coverage issue is just a re-formatted Since this has been a while I'm going to update the branch and push it to a twisted branch for full CI, but assuming CI is reasonably happy after that, I'll merge. |
Thanks to https://www.traviscistatus.com/incidents/3pfp91tltsbr I really didn't want to wait the additional 2 hours for another trunk merge, so: merged. |
(Happily the status just passed though, so no exception necessary!) |
Underway I had to fix a few bugs/annoyances. Most notably:
These should be deprecated ASAP.
I wrote a bunch of tests (the class was completely untested so far), but want to see Travis/coverage before writing more.