Skip to content

Refactoring: remove dead code from Raw display - #707

Merged
penguinolog merged 2 commits into
urwid:masterfrom
penguinolog:ref_dead_code
Dec 14, 2023
Merged

penguinolog merged 2 commits into
urwid:masterfrom
penguinolog:ref_dead_code

Conversation

@penguinolog

Copy link
Copy Markdown
Collaborator
  • CursesDisplay: stop using private namespace _curses for exceptions
  • Mass add typing for better static logic trace
Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)


super()._stop()

@typing.overload

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate from base class

b |= mod
result.extend([27, ord("["), ord("M"), b + 32, x + 32, y + 32])

def determine_button_release(flag: int) -> None:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used and unreachable from outside

signals.connect_signal(self, UPDATE_PALETTE_ENTRY, self._on_update_palette_entry)
self.colors: Literal[1, 16, 88, 256, 16777216] = 16 # FIXME: detect this
self.has_underline = True # FIXME: detect this
self._keyqueue = []

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used across whole project

return escape.set_cursor_position(0, 0)
return escape.CURSOR_HOME_COL + escape.move_cursor_up(cy)

def set_cursor_row(y):

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used and unreachable from outside

Comment thread urwid/display_common.py
if mono is None:
mono = DEFAULT
mono = AttrSpec(mono, DEFAULT, 1)
mono_spec = AttrSpec(mono, DEFAULT, 1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not replace variable and not confuse static analysis

@coveralls

coveralls commented Dec 14, 2023 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 7209892230

  • 57 of 86 (66.28%) changed or added relevant lines in 7 files are covered.
  • 3 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.4%) to 70.954%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/_posix_raw_display.py 9 10 90.0%
urwid/curses_display.py 1 8 12.5%
urwid/display_common.py 6 13 46.15%
urwid/_raw_display_base.py 16 30 53.33%
Files with Coverage Reduction New Missed Lines %
urwid/_posix_raw_display.py 1 12.29%
urwid/_raw_display_base.py 1 7.35%
urwid/util.py 1 89.75%
Totals Coverage Status
Change from base Build 7205354780: 0.4%
Covered Lines: 7606
Relevant Lines: 10810

💛 - Coveralls

Comment thread urwid/curses_display.py
self.has_color = False
self.s = None
self.cursor_state = None
self._keyqueue = []

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used across whole project

Comment thread urwid/old_str_util.py
SAFE_ASCII_BYTES_RE = re.compile(b"^[ -~]*$")

_byte_encoding = None
_byte_encoding: Literal["utf8", "narrow", "wide"] = "narrow"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use correct default value with minimal functionality

Comment thread urwid/display_common.py
pass

@abc.abstractmethod
def draw_screen(self, size: tuple[int, int], r: Canvas) -> None:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method is ultimately used by MainLoop - require to implement

* CursesDisplay: stop using private namespace `_curses` for exceptions
* Mass add typing for better static logic trace
Comment thread urwid/display_common.py Outdated

Default (fallback) is 80x24.
"""
return 24, 80

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring says columns, rows but return value suggests rows, columns

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original code removed above returned 80, 24

@penguinolog
penguinolog merged commit 08946eb into urwid:master Dec 14, 2023
@penguinolog
penguinolog deleted the ref_dead_code branch December 14, 2023 14:19
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.

3 participants