prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Sign In Failed - TypeError
  Good evening!
  
  I'm here on Linux, I've just tried to log in to my Rotki database created with 1.0.4 (using 1.0.5 now). After I type in my password and log in, I get the message
  
  > **Sign In Failed**
  > TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
  
  Now when I attempt to go back to 1.0.4 I get
  > **Sign In Failed**
  > DBUpgradeError: Your database version is newer than the version expected by the executable. Did you perhaps try to revert to an older rotkehlchen version?Please only use the latest version of the software.
  
  No big worries, I'm still evaluating the software to see if it can do what I need so there's not a ton of data in there. Just thought you should know. I'll be happy to help with debugging if I can. But kids, so... I'll do my best!
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `rotkehlchen/db/settings.py`
  Content:
  ```
  1 from typing import Any, Dict, NamedTuple, Union
  2 
  3 from rotkehlchen.constants.assets import S_USD
  4 from rotkehlchen.constants.timing import YEAR_IN_SECONDS
  5 from rotkehlchen.db.utils import str_to_bool
  6 from rotkehlchen.errors import DeserializationError
  7 from rotkehlchen.typing import FiatAsset, Timestamp
  8 from rotkehlchen.user_messages import MessagesAggregator
  9 
  10 ROTKEHLCHEN_DB_VERSION = 8
  11 DEFAULT_TAXFREE_AFTER_PERIOD = YEAR_IN_SECONDS
  12 DEFAULT_INCLUDE_CRYPTO2CRYPTO = True
  13 DEFAULT_INCLUDE_GAS_COSTS = True
  14 DEFAULT_ANONYMIZED_LOGS = False
  15 DEFAULT_PREMIUM_SHOULD_SYNC = False
  16 DEFAULT_START_DATE = '01/08/2015'
  17 DEFAULT_UI_FLOATING_PRECISION = 2
  18 DEFAULT_BALANCE_SAVE_FREQUENCY = 24
  19 DEFAULT_MAIN_CURRENCY = S_USD
  20 DEFAULT_DATE_DISPLAY_FORMAT = '%d/%m/%Y %H:%M:%S %Z'
  21 DEFAULT_SUBMIT_USAGE_ANALYTICS = True
  22 
  23 
  24 class DBSettings(NamedTuple):
  25     version: int = ROTKEHLCHEN_DB_VERSION
  26     last_write_ts: Timestamp = Timestamp(0)
  27     premium_should_sync: bool = DEFAULT_PREMIUM_SHOULD_SYNC
  28     include_crypto2crypto: bool = DEFAULT_INCLUDE_CRYPTO2CRYPTO
  29     anonymized_logs: bool = DEFAULT_ANONYMIZED_LOGS
  30     last_data_upload_ts: Timestamp = Timestamp(0)
  31     ui_floating_precision: int = DEFAULT_UI_FLOATING_PRECISION
  32     taxfree_after_period: int = DEFAULT_TAXFREE_AFTER_PERIOD
  33     balance_save_frequency: int = DEFAULT_BALANCE_SAVE_FREQUENCY
  34     include_gas_costs: bool = DEFAULT_INCLUDE_GAS_COSTS
  35     historical_data_start: str = DEFAULT_START_DATE
  36     eth_rpc_endpoint: str = 'http://localhost:8545'
  37     main_currency: FiatAsset = DEFAULT_MAIN_CURRENCY
  38     date_display_format: str = DEFAULT_DATE_DISPLAY_FORMAT
  39     last_balance_save: Timestamp = Timestamp(0)
  40     submit_usage_analytics: bool = DEFAULT_SUBMIT_USAGE_ANALYTICS
  41 
  42 
  43 def read_boolean(value: Union[str, bool]) -> bool:
  44     if isinstance(value, bool):
  45         return value
  46     elif isinstance(value, str):
  47         return str_to_bool(value)
  48 
  49     raise DeserializationError(
  50         f'Failed to read a boolean from {value} which is of type {type(value)}',
  51     )
  52 
  53 
  54 def db_settings_from_dict(
  55         settings_dict: Dict[str, Any],
  56         msg_aggregator: MessagesAggregator,
  57 ) -> DBSettings:
  58     specified_args: Dict[str, Any] = {}
  59     for key, value in settings_dict.items():
  60         if key == 'version':
  61             specified_args[key] = int(value)
  62         elif key == 'historical_data_start':
  63             specified_args[key] = str(value)
  64         elif key == 'eth_rpc_endpoint':
  65             specified_args[key] = str(value)
  66         elif key == 'ui_floating_precision':
  67             specified_args[key] = int(value)
  68         elif key == 'include_crypto2crypto':
  69             specified_args[key] = read_boolean(value)
  70         elif key == 'taxfree_after_period':
  71             specified_args[key] = int(value)
  72         elif key == 'balance_save_frequency':
  73             specified_args[key] = int(value)
  74         elif key == 'main_currency':
  75             specified_args[key] = FiatAsset(str(value))
  76         elif key == 'anonymized_logs':
  77             specified_args[key] = read_boolean(value)
  78         elif key == 'include_gas_costs':
  79             specified_args[key] = read_boolean(value)
  80         elif key == 'date_display_format':
  81             specified_args[key] = str(value)
  82         elif key == 'premium_should_sync':
  83             specified_args[key] = read_boolean(value)
  84         elif key == 'last_write_ts':
  85             specified_args[key] = Timestamp(int(value))
  86         elif key == 'last_data_upload_ts':
  87             specified_args[key] = Timestamp(int(value))
  88         elif key == 'last_balance_save':
  89             specified_args[key] = Timestamp(int(value))
  90         elif key == 'submit_usage_analytics':
  91             specified_args[key] = read_boolean(value)
  92         else:
  93             msg_aggregator.add_warning(
  94                 f'Unknown DB setting {key} given. Ignoring it. Should not '
  95                 f'happen so please open an issue in Github.',
  96             )
  97 
  98     return DBSettings(**specified_args)
  99
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/rotkehlchen/db/settings.py b/rotkehlchen/db/settings.py
  --- a/rotkehlchen/db/settings.py
  +++ b/rotkehlchen/db/settings.py
  @@ -68,7 +68,23 @@
           elif key == 'include_crypto2crypto':
               specified_args[key] = read_boolean(value)
           elif key == 'taxfree_after_period':
  -            specified_args[key] = int(value)
  +            # taxfree_after_period can also be None, to signify disabled setting
  +            if value is None:
  +                specified_args[key] = value
  +            else:
  +                int_value = int(value)
  +                if int_value <= 0:
  +                    value = None
  +                    msg_aggregator.add_warning(
  +                        f'A negative or zero value ({int_value}) for taxfree_after_period '
  +                        f'ended up in the DB. Setting it to None. Please open an issue in '
  +                        f'Github: https://github.com/rotki/rotki/issues/new/choose',
  +                    )
  +
  +                else:
  +                    value = int_value
  +
  +                specified_args[key] = value
           elif key == 'balance_save_frequency':
               specified_args[key] = int(value)
           elif key == 'main_currency':
  
verification_info: {"golden_diff": "diff --git a/rotkehlchen/db/settings.py b/rotkehlchen/db/settings.py\n--- a/rotkehlchen/db/settings.py\n+++ b/rotkehlchen/db/settings.py\n@@ -68,7 +68,23 @@\n         elif key == 'include_crypto2crypto':\n             specified_args[key] = read_boolean(value)\n         elif key == 'taxfree_after_period':\n-            specified_args[key] = int(value)\n+            # taxfree_after_period can also be None, to signify disabled setting\n+            if value is None:\n+                specified_args[key] = value\n+            else:\n+                int_value = int(value)\n+                if int_value <= 0:\n+                    value = None\n+                    msg_aggregator.add_warning(\n+                        f'A negative or zero value ({int_value}) for taxfree_after_period '\n+                        f'ended up in the DB. Setting it to None. Please open an issue in '\n+                        f'Github: https://github.com/rotki/rotki/issues/new/choose',\n+                    )\n+\n+                else:\n+                    value = int_value\n+\n+                specified_args[key] = value\n         elif key == 'balance_save_frequency':\n             specified_args[key] = int(value)\n         elif key == 'main_currency':\n", "issue": "Sign In Failed - TypeError\nGood evening!\r\n\r\nI'm here on Linux, I've just tried to log in to my Rotki database created with 1.0.4 (using 1.0.5 now). After I type in my password and log in, I get the message\r\n\r\n> **Sign In Failed**\r\n> TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'\r\n\r\nNow when I attempt to go back to 1.0.4 I get\r\n> **Sign In Failed**\r\n> DBUpgradeError: Your database version is newer than the version expected by the executable. Did you perhaps try to revert to an older rotkehlchen version?Please only use the latest version of the software.\r\n\r\nNo big worries, I'm still evaluating the software to see if it can do what I need so there's not a ton of data in there. Just thought you should know. I'll be happy to help with debugging if I can. But kids, so... I'll do my best!\n", "before_files": [{"content": "from typing import Any, Dict, NamedTuple, Union\n\nfrom rotkehlchen.constants.assets import S_USD\nfrom rotkehlchen.constants.timing import YEAR_IN_SECONDS\nfrom rotkehlchen.db.utils import str_to_bool\nfrom rotkehlchen.errors import DeserializationError\nfrom rotkehlchen.typing import FiatAsset, Timestamp\nfrom rotkehlchen.user_messages import MessagesAggregator\n\nROTKEHLCHEN_DB_VERSION = 8\nDEFAULT_TAXFREE_AFTER_PERIOD = YEAR_IN_SECONDS\nDEFAULT_INCLUDE_CRYPTO2CRYPTO = True\nDEFAULT_INCLUDE_GAS_COSTS = True\nDEFAULT_ANONYMIZED_LOGS = False\nDEFAULT_PREMIUM_SHOULD_SYNC = False\nDEFAULT_START_DATE = '01/08/2015'\nDEFAULT_UI_FLOATING_PRECISION = 2\nDEFAULT_BALANCE_SAVE_FREQUENCY = 24\nDEFAULT_MAIN_CURRENCY = S_USD\nDEFAULT_DATE_DISPLAY_FORMAT = '%d/%m/%Y %H:%M:%S %Z'\nDEFAULT_SUBMIT_USAGE_ANALYTICS = True\n\n\nclass DBSettings(NamedTuple):\n    version: int = ROTKEHLCHEN_DB_VERSION\n    last_write_ts: Timestamp = Timestamp(0)\n    premium_should_sync: bool = DEFAULT_PREMIUM_SHOULD_SYNC\n    include_crypto2crypto: bool = DEFAULT_INCLUDE_CRYPTO2CRYPTO\n    anonymized_logs: bool = DEFAULT_ANONYMIZED_LOGS\n    last_data_upload_ts: Timestamp = Timestamp(0)\n    ui_floating_precision: int = DEFAULT_UI_FLOATING_PRECISION\n    taxfree_after_period: int = DEFAULT_TAXFREE_AFTER_PERIOD\n    balance_save_frequency: int = DEFAULT_BALANCE_SAVE_FREQUENCY\n    include_gas_costs: bool = DEFAULT_INCLUDE_GAS_COSTS\n    historical_data_start: str = DEFAULT_START_DATE\n    eth_rpc_endpoint: str = 'http://localhost:8545'\n    main_currency: FiatAsset = DEFAULT_MAIN_CURRENCY\n    date_display_format: str = DEFAULT_DATE_DISPLAY_FORMAT\n    last_balance_save: Timestamp = Timestamp(0)\n    submit_usage_analytics: bool = DEFAULT_SUBMIT_USAGE_ANALYTICS\n\n\ndef read_boolean(value: Union[str, bool]) -> bool:\n    if isinstance(value, bool):\n        return value\n    elif isinstance(value, str):\n        return str_to_bool(value)\n\n    raise DeserializationError(\n        f'Failed to read a boolean from {value} which is of type {type(value)}',\n    )\n\n\ndef db_settings_from_dict(\n        settings_dict: Dict[str, Any],\n        msg_aggregator: MessagesAggregator,\n) -> DBSettings:\n    specified_args: Dict[str, Any] = {}\n    for key, value in settings_dict.items():\n        if key == 'version':\n            specified_args[key] = int(value)\n        elif key == 'historical_data_start':\n            specified_args[key] = str(value)\n        elif key == 'eth_rpc_endpoint':\n            specified_args[key] = str(value)\n        elif key == 'ui_floating_precision':\n            specified_args[key] = int(value)\n        elif key == 'include_crypto2crypto':\n            specified_args[key] = read_boolean(value)\n        elif key == 'taxfree_after_period':\n            specified_args[key] = int(value)\n        elif key == 'balance_save_frequency':\n            specified_args[key] = int(value)\n        elif key == 'main_currency':\n            specified_args[key] = FiatAsset(str(value))\n        elif key == 'anonymized_logs':\n            specified_args[key] = read_boolean(value)\n        elif key == 'include_gas_costs':\n            specified_args[key] = read_boolean(value)\n        elif key == 'date_display_format':\n            specified_args[key] = str(value)\n        elif key == 'premium_should_sync':\n            specified_args[key] = read_boolean(value)\n        elif key == 'last_write_ts':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'last_data_upload_ts':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'last_balance_save':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'submit_usage_analytics':\n            specified_args[key] = read_boolean(value)\n        else:\n            msg_aggregator.add_warning(\n                f'Unknown DB setting {key} given. Ignoring it. Should not '\n                f'happen so please open an issue in Github.',\n            )\n\n    return DBSettings(**specified_args)\n", "path": "rotkehlchen/db/settings.py"}], "after_files": [{"content": "from typing import Any, Dict, NamedTuple, Union\n\nfrom rotkehlchen.constants.assets import S_USD\nfrom rotkehlchen.constants.timing import YEAR_IN_SECONDS\nfrom rotkehlchen.db.utils import str_to_bool\nfrom rotkehlchen.errors import DeserializationError\nfrom rotkehlchen.typing import FiatAsset, Timestamp\nfrom rotkehlchen.user_messages import MessagesAggregator\n\nROTKEHLCHEN_DB_VERSION = 8\nDEFAULT_TAXFREE_AFTER_PERIOD = YEAR_IN_SECONDS\nDEFAULT_INCLUDE_CRYPTO2CRYPTO = True\nDEFAULT_INCLUDE_GAS_COSTS = True\nDEFAULT_ANONYMIZED_LOGS = False\nDEFAULT_PREMIUM_SHOULD_SYNC = False\nDEFAULT_START_DATE = '01/08/2015'\nDEFAULT_UI_FLOATING_PRECISION = 2\nDEFAULT_BALANCE_SAVE_FREQUENCY = 24\nDEFAULT_MAIN_CURRENCY = S_USD\nDEFAULT_DATE_DISPLAY_FORMAT = '%d/%m/%Y %H:%M:%S %Z'\nDEFAULT_SUBMIT_USAGE_ANALYTICS = True\n\n\nclass DBSettings(NamedTuple):\n    version: int = ROTKEHLCHEN_DB_VERSION\n    last_write_ts: Timestamp = Timestamp(0)\n    premium_should_sync: bool = DEFAULT_PREMIUM_SHOULD_SYNC\n    include_crypto2crypto: bool = DEFAULT_INCLUDE_CRYPTO2CRYPTO\n    anonymized_logs: bool = DEFAULT_ANONYMIZED_LOGS\n    last_data_upload_ts: Timestamp = Timestamp(0)\n    ui_floating_precision: int = DEFAULT_UI_FLOATING_PRECISION\n    taxfree_after_period: int = DEFAULT_TAXFREE_AFTER_PERIOD\n    balance_save_frequency: int = DEFAULT_BALANCE_SAVE_FREQUENCY\n    include_gas_costs: bool = DEFAULT_INCLUDE_GAS_COSTS\n    historical_data_start: str = DEFAULT_START_DATE\n    eth_rpc_endpoint: str = 'http://localhost:8545'\n    main_currency: FiatAsset = DEFAULT_MAIN_CURRENCY\n    date_display_format: str = DEFAULT_DATE_DISPLAY_FORMAT\n    last_balance_save: Timestamp = Timestamp(0)\n    submit_usage_analytics: bool = DEFAULT_SUBMIT_USAGE_ANALYTICS\n\n\ndef read_boolean(value: Union[str, bool]) -> bool:\n    if isinstance(value, bool):\n        return value\n    elif isinstance(value, str):\n        return str_to_bool(value)\n\n    raise DeserializationError(\n        f'Failed to read a boolean from {value} which is of type {type(value)}',\n    )\n\n\ndef db_settings_from_dict(\n        settings_dict: Dict[str, Any],\n        msg_aggregator: MessagesAggregator,\n) -> DBSettings:\n    specified_args: Dict[str, Any] = {}\n    for key, value in settings_dict.items():\n        if key == 'version':\n            specified_args[key] = int(value)\n        elif key == 'historical_data_start':\n            specified_args[key] = str(value)\n        elif key == 'eth_rpc_endpoint':\n            specified_args[key] = str(value)\n        elif key == 'ui_floating_precision':\n            specified_args[key] = int(value)\n        elif key == 'include_crypto2crypto':\n            specified_args[key] = read_boolean(value)\n        elif key == 'taxfree_after_period':\n            # taxfree_after_period can also be None, to signify disabled setting\n            if value is None:\n                specified_args[key] = value\n            else:\n                int_value = int(value)\n                if int_value <= 0:\n                    value = None\n                    msg_aggregator.add_warning(\n                        f'A negative or zero value ({int_value}) for taxfree_after_period '\n                        f'ended up in the DB. Setting it to None. Please open an issue in '\n                        f'Github: https://github.com/rotki/rotki/issues/new/choose',\n                    )\n\n                else:\n                    value = int_value\n\n                specified_args[key] = value\n        elif key == 'balance_save_frequency':\n            specified_args[key] = int(value)\n        elif key == 'main_currency':\n            specified_args[key] = FiatAsset(str(value))\n        elif key == 'anonymized_logs':\n            specified_args[key] = read_boolean(value)\n        elif key == 'include_gas_costs':\n            specified_args[key] = read_boolean(value)\n        elif key == 'date_display_format':\n            specified_args[key] = str(value)\n        elif key == 'premium_should_sync':\n            specified_args[key] = read_boolean(value)\n        elif key == 'last_write_ts':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'last_data_upload_ts':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'last_balance_save':\n            specified_args[key] = Timestamp(int(value))\n        elif key == 'submit_usage_analytics':\n            specified_args[key] = read_boolean(value)\n        else:\n            msg_aggregator.add_warning(\n                f'Unknown DB setting {key} given. Ignoring it. Should not '\n                f'happen so please open an issue in Github.',\n            )\n\n    return DBSettings(**specified_args)\n", "path": "rotkehlchen/db/settings.py"}]}