Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Prefer type(x) is int to isinstance(x, int) #14945

Merged
merged 2 commits into from Jan 31, 2023

Commits on Jan 30, 2023

  1. Perfer type(x) is int to isinstance(x, int)

    This covered all additional instances I could see where `x` was
    user-controlled.
    The remaining cases are
    
    ```
    $ rg -s 'isinstance.*[^_]int'
    tests/replication/_base.py
    576:        if isinstance(obj, int):
    
    synapse/util/caches/stream_change_cache.py
    136:        assert isinstance(stream_pos, int)
    214:        assert isinstance(stream_pos, int)
    246:        assert isinstance(stream_pos, int)
    267:        assert isinstance(stream_pos, int)
    
    synapse/replication/tcp/external_cache.py
    133:        if isinstance(result, int):
    
    synapse/metrics/__init__.py
    100:        if isinstance(calls, (int, float)):
    
    synapse/handlers/appservice.py
    262:        assert isinstance(new_token, int)
    
    synapse/config/_util.py
    62:        if isinstance(p, int):
    ```
    
    which cover metrics, logic related to `jsonschema`, and replication and
    data streams. AFAICS these are all internal to Synapse
    David Robertson committed Jan 30, 2023
    Copy the full SHA
    963c16f View commit details
    Browse the repository at this point in the history
  2. Changelog

    David Robertson committed Jan 30, 2023
    Copy the full SHA
    7c4a2b8 View commit details
    Browse the repository at this point in the history