PyCon UK 2025

Why, and how, all your Python code should be Declarative in the Age of Generative AI
2025-09-19 , Space 2

We'll explore the tools that the Python language and ecosystem give us to inject rich metadata into code, and how we can exploit this to maximum advantage in an age where code is cheap, but delivering value with it is still as hard as ever.


Python is an excellent scripting language, and its syntax and wider ecosystem have evolved over the past three and a half decades allowing it to be used to build (almost) anything.

However, the strength that this flexibility offers can also be a source of weakness: because it's so easy to write a script that simply does something, what that 'something' is, and why it's being done, often goes undocumented and forgotten. This is especially true in large organisations where individuals come and go, but scripts and applications stay put.

In recent years, particularly after the advent of the typing system in version 3.5, and then runtime annotations in 3.9, Python has begun to offer powerful ways to go beyond simply documenting code, and instead to record structured metadata about what code is doing and why, inside code itself. This has proven of particular use for framework builders and platform engineers, but is there for everyone involved with Python code and the technologies and processes we build with it to use.

This talk will cover some of these tools and patterns, before exploring their significance in the context of new generative-AI powered systems for writing code and building technology. In particular, we'll look at the uses and abuses of the typing module's Annotated object (a Special Form), and its integrations with essential libraries like Pydantic. The talk will then move on to explore other sources of metadata within our code, such as that recorded in frameworks like ORMs, API implementations, and explicit stores of metadata like pyproject.toml.

Most importantly of all, however, the talk will argue that as engineers working in a high level language, Pythonistas need to rethink what it means to write code in a world where there are tools that will so readily write it for us. Instead of writing code to do technical work, we instead need to develop deep understandings of our businesses, processes, projects, users, and colleagues, to structure and record what we want to do, and why.

We'll steer clear of "prompt engineering" and "vibe coding", and instead make a brief detour into the often misunderstood academic discipline of Geography to argue for a new approach to writing Python in 2025 and beyond.


What level of experience do you expect from your audience for this session?:

Not applicable

Dom Weldon is an independent contractor based in Central London, currently working in Platform Engineering at a large investment company in the City of London, having previously worked in a role specialising in AI/ML products across a variety of sectors.

He studied Natural Sciences at the University of Cambridge and Computational Geography at King's College London, and is particularly interested in the application of Graph Databases and Graph Theory in real world applications.

Outside work, Dom is interested in languages and travelling, and has a voluntary statutory role monitoring conditions for prisoners inside a challenging North London jail.