refactoring

Refactor to meet mypy requirements

偶尔善良 提交于 2021-01-01 17:49:56
问题 I have a codebase which I would like to validate using mypy. In the current design, it is very common that a class may have a non-primitive member that can be set later after __init__ . So, in __init__ the member is initialized to None and its type becomes Optional accordingly. The problem is that now MyPy requires me to check that the member is not None every time it is being used. As a quick solution I can add assert self._member is not None # MyPy in all the relevant scopes, but it seems

Refactor to meet mypy requirements

独自空忆成欢 提交于 2021-01-01 17:48:29
问题 I have a codebase which I would like to validate using mypy. In the current design, it is very common that a class may have a non-primitive member that can be set later after __init__ . So, in __init__ the member is initialized to None and its type becomes Optional accordingly. The problem is that now MyPy requires me to check that the member is not None every time it is being used. As a quick solution I can add assert self._member is not None # MyPy in all the relevant scopes, but it seems

How do I edit my program in order to assign a variable to an array list

拈花ヽ惹草 提交于 2020-12-15 06:47:45
问题 so I am currently working on a project for school. My initial program ran fine and then I was told to refactor my array into an array list. Eclipse is highlighting one specific line with the error that 'The lefthand side of an assignment must be a variable' . Everything else in the program seems to have no other issues. I have tried a few different things to fix this problem and have hit a wall. I've attached a copy of the section of code causing me issue, and I hope this question isn't too

ESLint - no-unused-expressions in ReactJS

情到浓时终转凉″ 提交于 2020-12-05 12:17:05
问题 Getting a ESLint error when copiling with babel: Line 28: Expected an assignment or function call and instead saw an expression no-unused-expressions Line 29: Expected an assignment or function call and instead saw an expression no-unused-expressions Any idea how to get rid of these whilst making my timer still work as intended? Or have you got a better way of me doing my timer? class RequestTimer extends Component { constructor(props) { super(props); this.state = { seconds: 0, minutes: 0,

ESLint - no-unused-expressions in ReactJS

自古美人都是妖i 提交于 2020-12-05 12:13:27
问题 Getting a ESLint error when copiling with babel: Line 28: Expected an assignment or function call and instead saw an expression no-unused-expressions Line 29: Expected an assignment or function call and instead saw an expression no-unused-expressions Any idea how to get rid of these whilst making my timer still work as intended? Or have you got a better way of me doing my timer? class RequestTimer extends Component { constructor(props) { super(props); this.state = { seconds: 0, minutes: 0,