pared: @shcheklein sure, I'm on it.
mroutis: @shcheklein, don't hesitate to request changes with the GitHub interface :)
pared: @shcheklein how about now? :)

shcheklein: @pared this is great! thanks :) 👍 
diff --git a/dvc/state.py b/dvc/state.py
index b2ca2a3cd..836b59ec3 100644
--- a/dvc/state.py
+++ b/dvc/state.py
@@ -263,8 +263,9 @@ class State(object):
                     m = st.st_mtime
                     if m > mtime:
                         mtime = m
-
-        return (str(int(nanotime.timestamp(mtime))), size)
+        # State of files handled by dvc is stored in db as TEXT.
+        # We cast results to string for later comparisons with stored values.
+        return str(int(nanotime.timestamp(mtime))), str(size)
 
     @staticmethod
     def inode(path):

state: investigate excessive checksum re-calculations
From discord:

> I added the file, which computed checksum.  Then I dvc pushed, which computed checksum.  Then I dvc run -d thatfile, which computed checksum after the command finished.  Then I dvc pushed again (to make sure it wasn't going to push the dir that I untarred), which is computing the checksum again.

diff --git a/tests/test_data_cloud.py b/tests/test_data_cloud.py
index d13eb4040..f9cdb8415 100644
--- a/tests/test_data_cloud.py
+++ b/tests/test_data_cloud.py
@@ -7,6 +7,7 @@ import shutil
 import getpass
 import platform
 import yaml
+from dvc.state import State
 from mock import patch
 
 import dvc.logger as logger
@@ -18,6 +19,7 @@ from dvc.remote.base import STATUS_OK, STATUS_NEW, STATUS_DELETED
 from dvc.utils import file_md5
 
 from tests.basic_env import TestDvc
+from tests.utils import spy
 
 try:
     from StringIO import StringIO
@@ -684,3 +686,16 @@ class TestRecursiveSyncOperations(TestDataCloudBase):
         self._test_recursive_fetch(data_md5, data_sub_md5)
 
         self._test_recursive_pull()
+
+
+class TestCheckSumRecalculation(TestDvc):
+
+    def test(self):
+        test_collect = spy(State._collect)
+        with patch.object(State, '_collect', test_collect):
+            url = get_local_url()
+            main(['remote', 'add', '-d', TEST_REMOTE, url])
+            main(['add', self.FOO])
+            main(['push'])
+            main(['run', '-d', self.FOO, 'echo foo'])
+        self.assertEqual(test_collect.mock.call_count, 1)
diff --git a/tests/unit/state.py b/tests/unit/state.py
new file mode 100644
index 000000000..b1608df10
--- /dev/null
+++ b/tests/unit/state.py
@@ -0,0 +1,13 @@
+from dvc.state import State
+from tests.basic_env import TestDvc
+
+
+class TestMtimeAndSizeReturnType(TestDvc):
+    def test(self):
+        file_time, file_size = State.mtime_and_size(self.DATA)
+        dir_time, dir_size = State.mtime_and_size(self.DATA_DIR)
+
+        self.assertIs(type(file_time), str)
+        self.assertIs(type(file_size), str)
+        self.assertIs(type(dir_time), str)
+        self.assertIs(type(dir_size), str)
diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py
index e69de29bb..0867f7924 100644
--- a/tests/utils/__init__.py
+++ b/tests/utils/__init__.py
@@ -0,0 +1,12 @@
+from mock import MagicMock
+
+
+def spy(method_to_decorate):
+    mock = MagicMock()
+
+    def wrapper(self, *args, **kwargs):
+        mock(*args, **kwargs)
+        return method_to_decorate(self, *args, **kwargs)
+
+    wrapper.mock = mock
+    return wrapper

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest>=3.3.1 mock>=2.0.0 coverage>=4.5.1 pytest
pip install --upgrade pip setuptools wheel
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
altgraph==0.17.4
appdirs==1.4.4
asciimatics==1.15.0
azure-common==1.1.28
azure-nspkg==3.0.2
azure-storage-blob==1.3.0
azure-storage-common==1.3.0
azure-storage-nspkg==3.1.0
bcrypt==4.3.0
boto3==1.7.4
botocore==1.10.84
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
colorama==0.4.6
configobj==5.0.9
configparser==7.2.0
coverage==7.8.0
cryptography==44.0.2
decorator==5.2.1
distro==1.9.0
docutils==0.21.2
-e git+https://github.com/iterative/dvc.git@b3df249c9f9ae0ff2b54f58845d7c2479be86232#egg=dvc
exceptiongroup==1.2.2
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==1.34.1
google-auth==2.38.0
google-cloud-core==0.28.1
google-cloud-storage==1.13.0
google-crc32c==1.7.1
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
idna==3.10
iniconfig==2.1.0
jmespath==0.10.0
jsonpath-rw==1.4.0
macholib==1.16.3
mock==5.2.0
nanotime==0.5.2
networkx==3.2.1
packaging==24.2
paramiko==3.5.1
pefile==2024.8.26
pillow==11.1.0
pluggy==1.5.0
ply==3.11
protobuf==3.20.3
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycparser==2.22
pydot==3.0.4
pyfiglet==1.0.2
PyInstaller==3.3.1
PyNaCl==1.5.0
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
rsa==4.9
s3transfer==0.1.13
schema==0.7.7
six==1.17.0
smmap==5.0.2
tomli==2.2.1
urllib3==2.3.0
wcwidth==0.2.13
zc.lockfile==3.0.post1

name: dvc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - altgraph==0.17.4
      - appdirs==1.4.4
      - asciimatics==1.15.0
      - azure-common==1.1.28
      - azure-nspkg==3.0.2
      - azure-storage-blob==1.3.0
      - azure-storage-common==1.3.0
      - azure-storage-nspkg==3.1.0
      - bcrypt==4.3.0
      - boto3==1.7.4
      - botocore==1.10.84
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - colorama==0.4.6
      - configobj==5.0.9
      - configparser==7.2.0
      - coverage==7.8.0
      - cryptography==44.0.2
      - decorator==5.2.1
      - distro==1.9.0
      - docutils==0.21.2
      - exceptiongroup==1.2.2
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-api-core==1.34.1
      - google-auth==2.38.0
      - google-cloud-core==0.28.1
      - google-cloud-storage==1.13.0
      - google-crc32c==1.7.1
      - google-resumable-media==2.7.2
      - googleapis-common-protos==1.69.2
      - grandalf==0.6
      - idna==3.10
      - iniconfig==2.1.0
      - jmespath==0.10.0
      - jsonpath-rw==1.4.0
      - macholib==1.16.3
      - mock==5.2.0
      - nanotime==0.5.2
      - networkx==3.2.1
      - packaging==24.2
      - paramiko==3.5.1
      - pefile==2024.8.26
      - pillow==11.1.0
      - pip==25.0.1
      - pluggy==1.5.0
      - ply==3.11
      - protobuf==3.20.3
      - pyasn1==0.6.1
      - pyasn1-modules==0.4.2
      - pycparser==2.22
      - pydot==3.0.4
      - pyfiglet==1.0.2
      - pyinstaller==3.3.1
      - pynacl==1.5.0
      - pyparsing==3.2.3
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - rsa==4.9
      - s3transfer==0.1.13
      - schema==0.7.7
      - setuptools==78.1.0
      - six==1.17.0
      - smmap==5.0.2
      - tomli==2.2.1
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc

tests/test_data_cloud.py::TestCheckSumRecalculation::test tests/unit/state.py::TestMtimeAndSizeReturnType::test
tests/test_data_cloud.py::TestDataCloud::test tests/test_data_cloud.py::TestRemoteLOCAL::test tests/test_data_cloud.py::TestDataCloudCLIBase::test tests/test_data_cloud.py::TestCompatRemoteLOCALCLI::test tests/test_data_cloud.py::TestRemoteLOCALCLI::test tests/test_data_cloud.py::TestRemoteSSHCLI::test tests/test_data_cloud.py::TestRemoteHDFSCLI::test tests/test_data_cloud.py::TestCompatRemoteS3CLI::test tests/test_data_cloud.py::TestRemoteS3CLI::test tests/test_data_cloud.py::TestCompatRemoteGSCLI::test tests/test_data_cloud.py::TestRemoteGSCLI::test tests/test_data_cloud.py::TestRemoteAzureCLI::test tests/test_data_cloud.py::TestDataCloudErrorCLI::test_error tests/test_data_cloud.py::TestWarnOnOutdatedStage::test tests/test_data_cloud.py::TestRecursiveSyncOperations::test
dvc/state.py
dvc/state.py