Patchwork D7675: util: move common proxyobserver attributes to the base class

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2019, 4:13 a.m.
Message ID <differential-rev-PHID-DREV-mzhryqyy3uzkjiupxsuu-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43849/
State Superseded
Headers show

Comments

phabricator - Dec. 16, 2019, 4:13 a.m.
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following pytype warnings:
  
    line 791, in _writedata: No attribute 'logdata' on baseproxyobserver [attribute-error]
    line 792, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
    line 793, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 794, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 799, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
    line 800, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 802, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 803, in _writedata: No attribute 'name' on baseproxyobserver [attribute-error]
    line 805, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 809, in _writedata: No attribute 'logdataapis' on baseproxyobserver [attribute-error]
    line 810, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 814, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]
    line 815, in _writedata: No attribute 'name' on baseproxyobserver [attribute-error]
    line 817, in _writedata: No attribute 'fh' on baseproxyobserver [attribute-error]

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7675

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -787,6 +787,12 @@ 
 
 
 class baseproxyobserver(object):
+    def __init__(self, fh, name, logdata, logdataapis):
+        self.fh = fh
+        self.name = name
+        self.logdata = logdata
+        self.logdataapis = logdataapis
+
     def _writedata(self, data):
         if not self.logdata:
             if self.logdataapis:
@@ -823,10 +829,7 @@ 
     def __init__(
         self, fh, name, reads=True, writes=True, logdata=False, logdataapis=True
     ):
-        self.fh = fh
-        self.name = name
-        self.logdata = logdata
-        self.logdataapis = logdataapis
+        super(fileobjectobserver, self).__init__(fh, name, logdata, logdataapis)
         self.reads = reads
         self.writes = writes
 
@@ -949,13 +952,10 @@ 
         logdata=False,
         logdataapis=True,
     ):
-        self.fh = fh
-        self.name = name
+        super(socketobserver, self).__init__(fh, name, logdata, logdataapis)
         self.reads = reads
         self.writes = writes
         self.states = states
-        self.logdata = logdata
-        self.logdataapis = logdataapis
 
     def makefile(self, res, mode=None, bufsize=None):
         if not self.states: